我使用以下代码片段将其放入 Python shell 程序中。这工作正常,但我只得到标准控制台。有没有办法做同样的事情但使用IPython http://ipython.scipy.org/ shell?
import code
class EmbeddedConsole(code.InteractiveConsole):
def start(self):
try:
self.interact("Debug console starting...")
except:
print("Debug console closing...")
def print_names():
print(adam)
print(bob)
adam = "I am Adam"
bob = "I am Bob"
print_names()
console = EmbeddedConsole(locals())
console.start()
print_names()
f3lix 的答案似乎不再有效,但是我找到了这个:
在 python 脚本的顶部:
from IPython import embed
无论您想在何处启动控制台:
embed()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)