python之类运用(八)

1、定义类 定义一个类,格式以下:php class 类名(object): 属性列表 方法列表 demo:定义一个Car类html class Car(object): # 属性 wheelNum = 2 color = 'red' # 方法 def getCarInfo(self): print('车轮子个数:%d, 颜色%s'%(self.wheelNum,
相关文章
相关标签/搜索