I'm getting the above error when I run the following code:
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."])
When I run it from PowerShell I get this error:
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):
Check your source code again. There's a discrepancy between the error message and your source. Your source says:
"so i will stop right here."])
but your error message says:
"so i will stop right here".])
A period outside instead of inside the quotes matters quite a bit!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.