怎么在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教程。
来源:PY学习网:原文地址:https://www.py.cn/article.html