<p>我对python还不熟悉,我遇到了麻烦。我学习了几门教程,但都没能克服错误:</p>
<pre><code>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'
</code></pre>
<p>我检查了几个教程,但似乎与我的代码没有什么不同。我唯一能想到的是Python3.3需要不同的语法。</p>
<p>主剪:</p>
<pre><code># test script
from lib.pump import Pump
print ("THIS IS A TEST OF PYTHON") # this prints
p = Pump.getPumps()
print (p)
</code></pre>
<p>泵等级:</p>
<pre><code>import pymysql
class Pump:
def __init__(self):
print ("init") # never prints
def getPumps(self):
# Open database connection
# some stuff here that never gets executed because of error
</code></pre>
<p>如果我理解正确,“self”会自动传递给构造函数和方法。我在这里做错什么了?</p>
<p>我将windows 8与python 3.3.2结合使用</p>