我们的想法是能够正常运行代码,除非它在到达特定方法调用时将在给定范围内启动交互式解释器.类似于在断点处停止以运行代码.
理想情况下,如果您已经在像ipython这样的解释器中,它将返回到该解释器,除了访问解释器范围之外的当前范围.
查看代码模块.
这是一个例子:
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)
| 归档时间: |
|
| 查看次数: |
75 次 |
| 最近记录: |