类
(在python2里)
1.属性
---数据属性
---函数属性
查看属性字典
class chinese: rz:'huangzhong' print(chinese.__dict__)
运行结果:
{'__module__': '__main__', '__annotations__': {'rz': 'huangzhong'}, '__dict__': <attribute '__dict__' of 'chinese' objects>, '__weakref__': <attribute '__weakref__' of 'chinese' objects>, '__doc__': None} Process finished with exit code 0
执行方法:
class chinese: rz:'huangzhong' def school(): print('333') print(chinese.__dict__) chinese.__dict__['school']()
运行结果:
{'__module__': '__main__', '__annotations__': {'rz': 'huangzhong'}, 'school': <function chinese.school at 0x7f5325d6cd90>, '__dict__': <attribute '__dict__' of 'chinese' objects>, '__weakref__': <attribute '__weakref__' of 'chinese' objects>, '__doc__': None} 333 Process finished with exit code 0