jupyter的使用整理--.ipynb文件和.py文件的相互转化
1、jupyter notebook中.ipynb文件和.py文件的相互转化
(1)jupyter notebook 生成py文件
法一:
在xxx.ipynb所在目录下,打开终端,并输入命令:
jupyter nbconvert --to script xxx.ipynb
其中xxx.ipynb是要转换文件的名字,转换后在该目录下出现xxx.py文件。
法二:
启动Jupyter notebook
在网页下找打ipynb文件,然后选择file–download as–python file
(2)jupyter notebook 加载py文件(即转为ipynb文件)
In [ ]:%run lhr.py
加载了lhr.py文件,相当于导包。
In [ ]:%load lhr.py
把lhr.py的代码显示出来。