Python_类属性的增删改查
class Human: def __init__(self,gender,langue,skin): self.gender = gender self.langue = langue self.skin = skin def speak(self): print("I speak %s" %self.langue) def skin_color(self): print("my skin color is %s" %self.skin) def gender_(self): print("Are U a man or a woman,,,,I am a %s" %self.gender) man1 = Human("female","Chinese","yellow") man1.skin_color() #增-数据属性 Human.country = "China" #增-方法属性 def eat_food(self, food_name): print("I am %s,,,I like eating %s" % (self.langue, food_name)) Human.eat = eat_food #给Human的eat属性赋值,这个值是一个方法 man1.eat("佛跳墙") #查 print("查的结果是:",Human.country) #改 Human.country = "Japan" #删 del Human.country