我正在學習Python和我試圖測試一些瞭解@property ... 這是我的代碼:道具()需要1周位置的說法,但分別給予2
class Thing:
def __init__(self, my_word=None):
self._word = my_word
def word(self):
return self._word
def prop(func):
def new():
return func(self)
return new()
thing = Thing('Im here')
thing.prop(thing.word)
我剛剛得到這個錯誤和它對我有點困惑。
Traceback (most recent call last):
File "E:/python projs/1/1.py", line 17, in <module>
thing.prop(thing.word)
builtins.TypeError: prop() takes 1 positional argument but 2 were given
現在我想這...什麼都沒有解決 –
@shiyonsufa嗯,這可能解決了原來的錯誤。是否有其他問題是一個不同的故事。 – Carcigenicate