小编给大家分享一下在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
看完了这篇文章,相信你对在jupyter上运行程序的方法有了一定的了解,想了解更多相关知识,欢迎关注天达云行业资讯频道,感谢各位的阅读!