首页 > IT职业 > IT生活 > 怎么在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视频教程。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/813/viewspace-2834319/ ,如需转载,请注明出处,否则将追究法律责任。