pdb.set_trace() 不工作 [英] pdb.set_trace() not working
问题描述
当我插入 import pdb;pdb.set_trace()
在我的代码中,它显示了一条错误消息:
When I insert import pdb; pdb.set_trace()
in my code, it shows an error message:
'module' 对象具有属性 'set_trace'
'module' object has attribute 'set_trace'
在pdb.py
文件中,有def set_trace()
函数.怎么可能不行?
In the pdb.py
file, there is the def set_trace()
function. How can it not work?
有没有人遇到过同样的问题并且知道如何解决这个问题?
Has anyone had the same problem and knows how to solve this?
推荐答案
您使用的是什么 Python 版本?如果我尝试 import pdb; 我可以重现那个错误.
.Python 3.8
上的 pdb.set_trace()
What Python version are you using?
I can reproduce that error if I try to import pdb; pdb.set_trace()
on Python 3.8
.
尝试使用 breakpoint()
代替(具有基本相同的目的),它对我有用!
Try to use breakpoint()
instead (has basically the same purpose), it worked for me!
干杯,
安德烈斯
Cheers,
Andres
这篇关于pdb.set_trace() 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!