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()

原文地址:https://www.cnblogs.com/Through-Target/p/12100432.html