如何使用类

ClassLLuffyStudent:

      school='luffycity' #数据属性

      def learn(self):    #函数属性

        print('is learning')

      def eat(self):  #函数属性

        print('is eating')

#查看类的名称空间

print(LuffyStudent._dict_)

print(LuffyStudent._dict_['school'])

print(LuffyStudent._dict_['learn'])

#查

print(LuffyStudent.school])

print(LuffyStudent.learn)

#增

LuffyStudent.county= 'china'

#删

del LuffyStudent.county= 'china'

#改

LuffyStudent.county= 'CHINA'

  

原文地址:https://www.cnblogs.com/kingforn/p/11301129.html