收起
def __init__()这里是两个下划线
def __init__()
class Commodit: def __init__(self, name, price, discount): self.name = name self.price = price self.discount = discount def show(self): print(self.name, self.price) oranges = Commodit('chengzi', 6, 0.9) oranges.show()
报告相同问题?