怎么在jupyter上运行程序?

467次阅读
没有评论

怎么在jupyter上运行程序?

在jupyter上运行程序的方法介绍:(推荐:jupyter使用教程)

先在目录下写.py的文件

def f(x, y, z):
    return (x + y) / z

a = 5
b = 6 
c = 7.5
result = f(a, b, c)

jupyter notebook 输入%load ipython_script_test.py:将脚本导入一个代码单元

# %load ipython_script_test.py
#!/usr/bin/env python

# In[8]:


def f(x, y, z):
    return (x + y) / z

a = 5
b = 6 
c = 7.5

result = f(a, b, c)

jupyter notebook 输入%run ipython_script_test.py:运行Python程序文件

%run ipython_script_test.py

输入c

c
7.5

更多python知识请关注python视频教程。

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:python工具2022-12-12发表,共计424字。
新手QQ群:570568346,欢迎进群讨论 Python51学习