面向对象
class Person: country = "China" def __init__(self, name, hp, aggr, sex): # self 实际上是一个大字典 self.name = name self.hp = hp self.aggr = aggr self.sex = sex def walk(self, n): print("%s走啊,走了%s步" % (self.name, n)) nxr = Person("nxr", 100, 1, "男") # nxr.age = 23 # nxr.name = "abc" # print(nxr.name) # nxr.walk(5) # print(nxr.name) # print(Person.__dict__["country"]) # print(nxr.__dict__["name"]) # nxr.__dict__["name"] = "二哥" # print(nxr.__dict__)