Skip to main content
 首页 » 编程设计

python之为什么我收到 AttributeError : 'module' object has no attribute 'set_trace'

2025年05月04日13shihaiming

import pdb  
print("program started")  
c=100  
d=200  
pdb.set_trace()  
def fun(a,b):  
    print a,b  
    return a+b  
fun(c,d)  
for i in [1,2,3,4,5]:  
    print 10/i  
    print ("other statements in program")  
print ("program ended") 

请您参考如下方法:

python 模块pdb 有一个set_trace() 函数。由于您的程序没有找到它,它正在导入其他东西。几乎可以肯定,您将程序(或同一目录中的另一个程序)命名为 pdb.py。