您可以ipshell()
从另一个用户定义的函数中调用,例如ipsh()
from inspect import currentframe
def ipsh():
frame = currentframe().f_back
msg = 'Stopped at {0.f_code.co_filename} and line {0.f_lineno}'.format(frame)
ipshell(msg,stack_depth=2) # Go back one level!
然后,ipsh()
在需要插入IPython shell的任何时候使用。