How to create a static variable in python?

This question already has an answer here:

  • Are static class variables possible? 16 answers

  • 为了使用静态变量,你必须在类中使用它。

     class XYZ:
         value = 3
    
    
     print(MyClass.value) //  access it via class name
    

    How's

    class A(object):
        v = 123
    

    You access it simply as

    A.v
    
    链接地址: http://www.djcxy.com/p/78782.html

    上一篇: 如何为使用它的所有类/实例保留唯一的数据?

    下一篇: 如何在python中创建一个静态变量?