Python error TypeError: __init__() takes exactly 2 arguments (1 given)

后端 未结 1 1175
刺人心
刺人心 2021-01-27 05:13

WHilst programming in Python i have come across this error about needing 2 arguments and only having one.

TypeError: __init__() takes exactly 2 arguments (1 give         


        
1条回答
  •  粉色の甜心
    2021-01-27 05:41

    Your NPCHandler class requires an argument (npcId), but when you create a new object inside GetNPCHandler, you are passing no arguments.

    The reason the error message says you are passing one argument is that self is passed implicitly. You need to also pass the second argument (npcId).

    0 讨论(0)
提交回复
热议问题