__author__ = '12711'
#-*- coding:utf-8 -*-
class Dog(object):
def __init__(self,name,age):
self.name=name
self.age=age
def Yell(self,cry):
self.cry=cry
print('%s%s叫了起来'%(self.name,self.cry))
def Eat(self):
print("%s吃了起来"%(self.name))
t=Dog('xiaohua',2)
str=input("qingshuru:")
if hasattr(t,str):#判断字符串是否存在
delattr(t,str)
# T=getattr(t,str)#调用方法
# T('wangwang')
#setattr(t,str,'xiaobai')
else:
# setattr(t,str,Eat)#增加方法
# t.Eat(t)
setattr(t,str,"baise")#增加属性x.y='V'
print(getattr(t,str))
print(t.name)