要在一个python shell(如Idle或Django shell)中运行python脚本,可以使用exec()函数执行以下操作。 Exec()执行一个代码对象参数。 Python中的代码对象是简单编译的Python代码。 所以你必须先编译你的脚本文件,然后使用exec()来执行它。 从你的shell: >>>file_to_compile = open('/path/to/your/file.py').read...