私のエラーに関してここでいくつかの答えを見ましたが、それは私を助けませんでした。私はPythonのクラスで絶対的なnoobであり、ちょうど9月にこのコードをやり始めました。とにかく私のコードTypeError:__init __()は3つの引数をとります(2が指定されています)
class SimpleCounter():
def __init__(self, startValue, firstValue):
firstValue = startValue
self.count = startValue
def click(self):
self.count += 1
def getCount(self):
return self.count
def __str__(self):
return 'The count is %d ' % (self.count)
def reset(self):
self.count += firstValue
a = SimpleCounter(5)
を見て、これは私が2つの入力値、startValue
とfirstValue
ため
Traceback (most recent call last):
File "C:\Users\Bilal\Downloads\simplecounter.py", line 26, in <module>
a = SimpleCounter(5)
TypeError: __init__() takes exactly 3 arguments (2 given
ちなみに、あなたのクラスは、(あなたがなぜ興味がある場合のpython新しいスタイルのクラスのためのgoogle)object' 'から継承しなければなりません – ThiefMaster