几种方法。
从外壳
python someFile.py
从IDLE内部,按 F5 。
如果您是交互式输入,请尝试以下操作:( 仅适用于Python 2 !)
>>> variables= {}>>> execfile( "someFile.py", variables )>>> print variables # globals from the someFile module对于Python3 ,请使用:
>>> exec(open("filename.py").read())
几种方法。
从外壳
python someFile.py
从IDLE内部,按 F5 。
如果您是交互式输入,请尝试以下操作:( 仅适用于Python 2 !)
>>> variables= {}>>> execfile( "someFile.py", variables )>>> print variables # globals from the someFile module对于Python3 ,请使用:
>>> exec(open("filename.py").read())