我正在运行我的Python程序,在某个点上,可以跳进去看一下发生了什么,然后再跳出来。有点像一个临时的控制台模式。
在Matlab中,我会使用 keyboard
命令来实现这个功能,但我不知道在Python中该怎么做。
有没有办法做到这一点?
例如:
for thing in set_of_things:
enter_interactive_mode_here()
do_stuff_to(thing)
当调用 enter_interactive_mode()
函数时,我想进入其中,查看周围情况,然后离开并让程序继续运行。
code.InteractiveInterpreter
类,然后总有exec
。 - martineau