我使用下面的代碼片段放入一個Python shell中程序。這工作正常,但我只得到標準控制檯。有沒有辦法做到這一點,但使用IPython外殼?我可以在嵌入式交互式Python控制檯中使用IPython嗎?
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()
請問您現在可以標記Dereck的答案嗎? – 2015-10-06 01:36:21