Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在python中创建静态变量?_Java_Python_Class_Variables_Static - Fatal编程技术网

Java 如何在python中创建静态变量?

Java 如何在python中创建静态变量?,java,python,class,variables,static,Java,Python,Class,Variables,Static,我在python中搜索了很多静态变量,但没有找到直接的答案 . 就像java在一个类中将变量定义为静态一样,python也可以这样做吗 要使用静态变量,必须在类内使用它 class XYZ: value = 3 print(MyClass.value) // access it via class name 怎么样 您只需按以下方式访问它: A.v 在类中定义变量。请注意,python支持OO的概念,但不是OO。它是多方面的。 A.v

我在python中搜索了很多静态变量,但没有找到直接的答案
. 就像java在一个类中将变量定义为静态一样,python也可以这样做吗

要使用静态变量,必须在类内使用它

 class XYZ:
     value = 3


 print(MyClass.value) //  access it via class name
怎么样

您只需按以下方式访问它:

A.v

在类中定义变量。请注意,python支持OO的概念,但不是OO。它是多方面的。
A.v