<分区> 分区>
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)
