class Bird:
def __init__(self):
self.noise = "chirping"
self.beak = "closed"
self.wings = "closed"
def __str__(self):
msg = "The bird is ", self.noise "its beak is ",
self.beak "its wings are ", self.wings
return msg
mybird = Bird()
print(mybird)
問題は何かを完全にはわかりませんが、私はこれを使ってBirdオブジェクトを印刷する必要があります。文字列と変数を変数に割り当てる方法
は私を与えた。これは、エラーのpythonです:
Traceback (most recent call last):
File "D:/000- Python-Coding/Practice/ bird object program.py", line 10, in <module>
print(mybird)
TypeError: __str__ returned non-string (type tuple)
ああ..私は、私はそれを試してみましたと思ったが、おかげで、それは動作します。 – Anonymous