【发布时间】:2019-12-11 07:48:59
【问题描述】:
当我使用 python -i file.py 运行脚本并收到错误时,我想找出该变量的值。但是它在一个类中,而不是一个实例中。
class Foo:
def func(self):
action_dict = self.socket_resp() # a function that recieves some response from a socket.
print(action_dict['bar'])
python -i foo.py
KeyError 在 action_dict 中没有'bar'
action_dict
NameError: name 'action_dict' is not defined'
如何在交互模式下获取 action_dict 变量的值
【问题讨论】:
-
它不在一个类中,而是在一个方法中
-
不,你不能那样做。以交互方式运行 python 程序与使用 interactive source code debugger 运行它是不同的
标签: python shell debugging interactive