首页 > 编程语言 > 详细

python中类的调用

时间:2019-12-26 10:11:37      阅读:94      评论:0      收藏:0      [点我收藏+]
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()

技术分享图片

python中类的调用

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!