#类属性又称为静态变量,或者是静态数据,这些数据是他们所属的类对象绑定的,不依赖于任何类实例

class ChinesePeople:
country = 'china'
def __init__(self,name):
self.name = name
def play_ball(self,ball):
print ("%s 正在打 %s" %(self.name))
def say_word(self,word):
print ("%s 说 %s" %(self.name,word))

#查看类属性
print (ChinesePeople.country)
#修改类属性
ChinesePeople.country = "CHINA"
print ChinesePeople.country
#删除类属性
del ChinesePeople.country
#增加类属性
ChinesePeople.country = "china"
ChinesePeople.location = "Asia"
print (ChinesePeople.__dict__)
posted on 2018-05-02 11:44  wy0925  阅读(141)  评论(0编辑  收藏  举报