访问权限 _.name 只能再同一个类,或者字类中可用 __.name 不能再任何类外使用 类属性 # 查看对象的类名 print(xiaoming.__class__) # 通过类名进行访问 print(Person.nation) # 查看类的名字 print(Person.__name__) # 查看父类元组 print(Person.__bases__) # 类相关的信息 print(Person.__dict__) # 查看继承链顺序 print(Person.__mro__) xiaoming.age = 20 # 不能添加,因为没有在Person.slots类属性中 # xiaoming.height = 180 # 显示对象能够使用的属性 print(Person.__slots__)
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。
还木有评论哦,快来抢沙发吧~