TypeError:缺少一個(gè)必需的位置參數(shù):‘Self’我對(duì)蟒蛇很陌生,撞到了墻上。我遵循了幾個(gè)教程,但無(wú)法克服這個(gè)錯(cuò)誤:Traceback (most recent call last):
File "C:\Users\Dom\Desktop\test\test.py", line 7, in <module>
p = Pump.getPumps()TypeError: getPumps() missing 1 required positional argument: 'self'我研究了幾個(gè)教程,但似乎與我的代碼沒有什么不同。我唯一能想到的是python3.3需要不同的語(yǔ)法。主枕:# test scriptfrom lib.pump import Pumpprint ("THIS IS A TEST OF PYTHON") # this printsp = Pump.getPumps()print (p)泵級(jí):import pymysqlclass Pump:
def __init__(self):
print ("init") # never prints
def getPumps(self):
# Open database connection
# some stuff here that never gets executed because of error如果我正確理解,“Self”將自動(dòng)傳遞給構(gòu)造函數(shù)和方法。我在這里做錯(cuò)什么了?我使用Windows 8和python 3.3.2
TypeError:缺少一個(gè)必需的位置參數(shù):‘Self’
拉風(fēng)的咖菲貓
2019-07-06 16:47:54