python出现TypeError: 'module' object is not callable错误

由于工作原因经常会写一个类来重复调用,但是偶尔会出现TypeError: 'module' object is not callable错误

  File "/home/yu/Downloads/cp0/people/views.py", line 116, in test_o
    owner = str(Patches(data).owner)
TypeError: 'module' object is not callable


经过检查多次发现类在调用的时候在views.py中直接import Patches(包含该类的py是Patches.py)

使用from Patches import Patches调用即可




你可能感兴趣的:(Python)