#定义一个类
class Cup():
def drink(self):
print(‘喝饮料’)
def print_info(self):
print(f’杯子高度{self.kuandu}’)
print(f’杯子高度{self.high}’)
makebei = Cup()
makebei.kuandu = 10
makebei.high = 11
#对象调用实例方法
makebei.print_info()
运行打印如下:
杯子高度10
杯子高度11
#定义一个类
class Cup():
def drink(self):
print(‘喝饮料’)
def print_info(self):
print(f’杯子高度{self.kuandu}’)
print(f’杯子高度{self.high}’)
makebei = Cup()
makebei.kuandu = 10
makebei.high = 11
#对象调用实例方法
makebei.print_info()
运行打印如下:
杯子高度10
杯子高度11