面向对象1 -11.10 欠缺
2017-11-10 本文已影响0人
冬gua
1.1定义类
定义一个类,格式如下:
class类名:
方法列表
demo:定义一个Car 类
#定义类
classCar:
#方法
def getCarInfo (self):
print('车轮子个数:%d,颜色%s'%(self.wheelNum, self.color))
def move (self):
print ("车正在移动...")
![](https://img.haomeiwen.com/i8777419/1fdbf7c324bbb2fe.png)
![](https://img.haomeiwen.com/i8777419/aa53ec6c0e1a46aa.png)
![](https://img.haomeiwen.com/i8777419/59274d12ac0c3879.png)
![](https://img.haomeiwen.com/i8777419/6aa968a32cb653be.png)
1.1定义类
定义一个类,格式如下:
class类名:
方法列表
demo:定义一个Car 类
#定义类
classCar:
#方法
def getCarInfo (self):
print('车轮子个数:%d,颜色%s'%(self.wheelNum, self.color))
def move (self):
print ("车正在移动...")