# -*- coding: UTF-8 -*- class Person(): city = 'BeiJing' # 类的数据属性 def __init__(self, name, age): self.name =name # 实例对象的数据属性 self.age = age def run(self): # 类的函数属性 print(f"{self.name} is talk") xdc = Person('xdc', 18) xiguatian = Person('xiaoguatian', 19) # 所有的实例都可以调用类的所有属性 print(xdc.city) xdc.run() print(xiguatian.city) xiguatian.run()