我怎样才能在IPython中获得类似Spyder的runfile
功能?(我在 Python 2.7.9 下使用 IPython v.4.1.2。)
可以使用 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)
有关如何在工作目录之外运行文件的更多信息可以在此答案中找到。
归档时间: |
|
查看次数: |
4289 次 |
最近记录: |