相当于 IPython 的 Spyder 运行文件吗?

kjo*_*kjo 5 python ipython

我怎样才能在IPython中获得类似Spyder的runfile功能?(我在 Python 2.7.9 下使用 IPython v.4.1.2。)

cma*_*her 5

可以使用 magic 命令在 IPython 环境中执行 Python 文件%run

例子:

print_time.py
# #!/usr/bin/python
# 
# from datetime import datetime
# 
# print "The current time is {}".format(datetime.now().strftime("%H:%M:%S"))

In [1]: %run print_time.py
The current time is 21:37:46
Run Code Online (Sandbox Code Playgroud)

有关如何在工作目录之外运行文件的更多信息可以在此答案中找到。