[英]object takes no parameters
运行以下代码时出现上述错误:
class Song(object):
def _init_(self,lyrics):
self.lyrics=lyrics
happy_bday = Song([ "happy birthday to you.",
"i don't want to get sued.",
"so i will stop right here."])
当我从PowerShell运行它时,出现此错误:
Traceback (most recent call last):
File "qa.py", line 12, in <module>
"so i will stop right here".])
TypeError:object() takes no parameters
您的init
方法每边需要2 _
,而不仅仅是1
def __init__(self, lyrics):
再次检查您的源代码。 错误消息和您的来源之间存在差异。 您的消息来源说:
"so i will stop right here."])
但您的错误消息显示:
"so i will stop right here".])
用引号括起来而不是用句号来代替!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.