ITPub博客

首页 > IT职业 > IT生活 > 怎么在jupyter上运行程序?

怎么在jupyter上运行程序?

IT生活 作者:llittle 时间:2021-09-11 10:20:42 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视频教程。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/813/viewspace-2834319/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-12

  • 博文量
    448
  • 访问量
    4359