2021年4月24日 星期六

[ Python 常見問題 ] How to execute a * .PY file from a * .IPYNB file on the Jupyter notebook?

 Source From Here

Question
I am working on a Python Notebook and I would like that large input code [input] pack into a [* .PY] files and call this file from the notebook.

HowTo
In the %run magic documentation you can find:
-i run the file in IPython’s namespace instead of an empty one. This is useful if you are experimenting with code written in a text editor which depends on variables defined interactively.

Therefore, supplying -i does the trick:
  1. %run -i 'script.py'  

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...