How to define globals?
This question already has an answer here:
In Python there are no true constants. The closest thing you can do is create a variable and never reassign it. Your attempt looks like it will work fine.
One thing to note is that "constant and true" does not mean "global". The distinguishing feature of a global variable has nothing to do with constancy, but the scope at which the object can be referenced (namely, all). You can have global variables that aren't constant (in languages that allow constants, of course), and constant variables that are not global.
我真的不知道你想要达到什么目的,并且从你想要保护“常数”的值而来,但是创建一个numpy memmap数组的一个可能的解决方案,给它赋值并且再次打开它作为read只要。
链接地址: http://www.djcxy.com/p/91748.html上一篇: 在Python 2中创建常量
下一篇: 如何定义全局变量?