try: !jupyter nbconvert --to python 文件名 #将ipython 转为.py except: pass 在ipynb文件最后一行加入此代码,同时保证文件名和ipynb文件的文件名一致。