python中类的调用

1 class Computer:    # 创建类,类名首字母大写
2     screen = True  # 类的属性
3 
4     def start(self):  # 创建实例方法,不要漏了 self
5         print('电脑正在开机中……')
6 
# 类的实例化,实例名等于类名;调用的语法是实例名.属性实例名.方法 7 my_computer = Computer() 8 print(my_computer.screen) 9 my_computer.start()

posted on 2019-12-26 09:46  Through-Target  阅读(3287)  评论(0编辑  收藏  举报

导航