from IPython import embed

在pycharm中运行如下代码
from IPython import embed
a = 10
b = 20
embed(header='First time')
c = 30
d = 40
embed()
运行结果如下:

Python 3.6.3 |Anaconda, Inc.| (default, Oct  6 2017, 12:04:38) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
First time
In [1]: a = 30
In [2]: b = 20
In [3]: print(a+b)
50

In [4]: 

调用此项以在程序的当前点嵌入 IPython,第一次调用embed()将创建一个 InteractiveShellEmbed 实例, 然后调用它。连续调用只调用已经创建的实例。





你可能感兴趣的:(python基础,ipython)