7_19 day24 22min类属性增删改查

class Chinese:
"cdfgrgfrth"
country='China'
def __init__(self,name):
self.name=name

def play_ball(self,ball):
print('%s 正在打 %s' %(self.name))
#查看
print(Chinese.country)

#修改
Chinese.country='Japan'
print(Chinese.country)

p1=Chinese('alex')
print(p1.__dict__)
print(p1.country)

#增加
Chinese.dang='党'
p1.shabi="dds"
print(Chinese.dang)
print(p1.dang)
print(p1.shabi)
print(p1)
print(Chinese.__dict__)
print(Chinese.__doc__)
# #删除
# del Chinese.dang
# del Chinese.country
#
# print(Chinese.__dict__)
# # print(Chinese.country)
#
#增加函数
def eat_food(self,food):
print('%s 正在吃%s' %(self.name,food))

Chinese.eat=eat_food

# print(Chinese.__dict__)
# p1.eat('屎')
#
#
def test(self):
print('test')

Chinese.play_ball=test
p1.play_ball()# Chinese.play_ball(p1)
posted @ 2018-07-19 04:50  一棵大树一棵小树一棵草  阅读(119)  评论(0编辑  收藏  举报