【发布时间】:2016-02-16 18:45:06
【问题描述】:
从命令行运行 Python 非常好和容易。特别是用于测试目的。 唯一的缺点是,在对脚本进行更改后,我必须重新启动 Python,重新执行所有导入,创建对象并输入参数。
$ python
>>> from foo import bar
>>> from package.file import Class
>>> c = Class
>>> c.name = "John"
>>> c.age = 33
>>> c.function()
>>> from datetime import timedelta, datetime
>>> now = datetime.now().year()
>>> next_year = now + timedelta(year=1)
>>> etc...
谁能告诉我是否有一种更简单的方法,然后每次我对 Python 代码进行更改时一遍又一遍地完成所有工作?
【问题讨论】:
-
如果您在更改脚本后更清楚自己想要做什么,这将有所帮助。你在测试功能吗?
标签: python command-line