Dreamer_Luo edited 3 年,3 月前
定义一个类:
class Person(object):
def __init__(self, name=None, age=None): //默认值为None
self.name = name
self.age = age
def run(self):
print("{}在奔跑".format(self.name))
def jump(self):
print("{}在跳跃".format(self.name))
定义对象实例化类:
xiaomu = Person(“小慕”)
xiaomu.run();
xiaomu.jump();