品易云推流 关闭
文章详情页
文章 > Jupyter > 怎么在jupyter上运行程序?

怎么在jupyter上运行程序?

头像

yang

2020-02-22 10:23:128618浏览 · 0收藏 · 0评论

在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视频教程

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图