是否有一些东西可以放在你的代码中启动一个交互式的interperter(在python中)

wn-*_*wn- 4 python debugging

我们的想法是能够正常运行代码,除非它在到达特定方法调用时将在给定范围内启动交互式解释器.类似于在断点处停止以运行代码.

理想情况下,如果您已经在像ipython这样的解释器中,它将返回到该解释器,除了访问解释器范围之外的当前范围.

GWW*_*GWW 5

查看代码模块.

这是一个例子:

import code
a = 1
b = 2
code.interact(local=locals())
Run Code Online (Sandbox Code Playgroud)

输出:

Python 2.7 (r27:82500, Nov 10 2010, 22:46:43) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> a
1
>>> b
2
>>>
Run Code Online (Sandbox Code Playgroud)


Ign*_*ams 2

你要code

  • 很多人来到 StackOverflow 是因为他们想要代码。只是一个观察:-) (5认同)