7886人加入学习
(35人评价)
Python零基础入门学习2020最新版(SiKi)

使用Python3.8 于2019/10/20开始录制

价格 免费

添加属性的默认值:

class Car():
    def __init__(self, make,model,year):
        self.make = make
        self.model = model
        self.year = year
        self.mileage = 0

    def describe(self):
        print(self.year + ' ' + self.make + ' ' + self.model)

    def get_mileage(self):
        print('the mileage is ' + str(self.mileage))

car1 = Car('奥迪', 'K1', '2010')
car1.describe()
car1.get_mileage()

[展开全文]