01/10/2018, 17:16
Lỗi take no arguments
class Song(object):
def _init_(self, lyrics):
self.lyrics =lyrics
def sing_me_a_song(self):
for line in self.lyrics:
print(line)
happy_bday= Song(["Happy birthday to you","i don't want to get sued","so i'll stop right there"])
bulls_on_parade = Song(["they rally aroung tha family","with pockets full of shells"])
happy_bday.sing_me_a_song()
bulls_on_parade.sing_me_a_song()
cho em hỏi đoạn code thế này khi chạy thì nó báo lỗi dòng happy_bday = song…
báo là take no arguments . lỗi này như thế nào và em sửa như thế nào ạ. em cám ơn
Bài liên quan
Là 2 gạch dưới
__init__
không phải_init_
ok dc rồi cám ơn bạn nhưng cho mình hỏi là init là bắt buộc là như thế hay có thể đổi thành tên khác như teo hay gì ko ạ. self cũng như thế có đổi dc ko hay bắt buộc như vậy ạ
BẮT BUỘC do ngôn ngữ quy định nha.