我想要一个类似的脚本:
x = 1
x += 1
exit
当我按顺序输入这些内容到ipython时。
如果我尝试将这些文件放在script.py中并执行%run script.py,则它不起作用(%run -i也不起作用):
In [1]: %run test.py
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
/Users/david/nice_pngs/test.py in <module>()
1 x = 1
2 x += 1
----> 3 exit
NameError: name 'exit' is not defined
In [2]: %run -i test.py
In [3]: