2024-05-28 19:28:09 发布
网友
我正在编写一个简短的教程,希望能够使用python的doctest使用
python -m doctest foo.txt
教程中有一点我想开始使用一个新的干净的python解释器。有这样做的机制吗?
如果您只想在python解释器中启动一个新的python解释器,那么只需发出命令:os.system('python')
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> dir() ['__builtins__', '__doc__', '__name__', '__package__'] >>> import os >>> dir() ['__builtins__', '__doc__', '__name__', '__package__', 'os'] >>> os.system('python') Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> dir() ['__builtins__', '__doc__', '__name__', '__package__'] >>> quit() 0 >>> dir() ['__builtins__', '__doc__', '__name__', '__package__', 'os'] >>>
但是,如果您想重新启动或重置python解释器,而不是像上面那样启动一个新的python解释器,那么您可以看看这个解决方案。我还没有探索过,但应该能帮你开始。
Restarting a Python Interpreter Quietly
如果您只想在python解释器中启动一个新的python解释器,那么只需发出命令:os.system('python')
但是,如果您想重新启动或重置python解释器,而不是像上面那样启动一个新的python解释器,那么您可以看看这个解决方案。我还没有探索过,但应该能帮你开始。
Restarting a Python Interpreter Quietly
相关问题 更多 >
编程相关推荐