# 类变量在定义阶段就会执行 class Luffycity: school = 'students' def eat(self): print('is eatting') def sleep(self): print('is sleeping') def learn(self): print('is learning') print("===run===") #|********************属性操作(增删改查)********************** # 查看类的名称空间 ===> print( 类名 .__dict__) # 查看本质是使用===>类的变量名.__dict__['对应变量名或者函数名'] print(Luffycity.__dict__) #称为名称空间,含类中的所有东西; print(Luffycity) #而 print(luffycity)显示<class '__main__.Luffycity'> 类名 print(Luffycity.__dict__['school']) print(Luffycity.__dict__['eat']) #查 print(Luffycity.school) print(Luffycity.eat) print(Luffycity.learn) #增 Luffycity.country = 'China' # 增加变量 print(Luffycity.country) #打印 增加的变量值 如何增加一个函数呢??? Luffycity.cook =(print('is cooking')) #想增加一个函数,显示==>'cook': None,不知道对不对 #修 Luffycity.school = 'Student' print(Luffycity.school) #删 del Luffycity.country print(Luffycity.__dict__) # 打印Luffycity.__dict__ 与 Luffycity 结果不同??(猜:一个是内存地址,一个是含着的所有的东西) #********************属性操作(增删改查)**********************