% run 命令

作者: 庵下桃花仙 | 来源:发表于2018-12-03 22:33 被阅读7次

先在目录下写.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

输入result

result
1.4666666666666666

相关文章

网友评论

    本文标题:% run 命令

    本文链接:https://www.haomeiwen.com/subject/rqzucqtx.html