zoukankan      html  css  js  c++  java
  • python学习-61 类

                                                   类

    (在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
  • 相关阅读:
    HGOI20191115 模拟赛 题解
    HGOI20191114 CSP模拟赛 反思
    HGOI 20191108 题解
    HGOI 20191107 题解
    HGOI 20191106 题解
    HGOI 20191105 题解
    HGOI 20191103am 题解
    HGOI 20191101am 题解
    HGOI 20191031am 题解
    新的博客!!!
  • 原文地址:https://www.cnblogs.com/liujinjing521/p/11433262.html
Copyright © 2011-2022 走看看