python之类和对象

class Transport:
'交通工具'

def __init__(self,name, type, place):
self.name=name
self.type=type
self.place=place

function='运输'
def pick(self):
print('%s%s在%s上跑' % (self.name,self.type,self.place))
car=Transport('林肯','汽车','陆地')
Transport.pick(car)
car.time='10 year'
print(car.function)
def test(self):
print('%s起步速度快'%self.name)
Transport.test=test
Transport.test(car)

猜你喜欢

转载自www.cnblogs.com/cxydnxs/p/12327053.html