为一个变量分配一个以上的大写字母

assign a variable with more than one capital letter

我认为我的问题很愚蠢。我正在使用 windows / Python 3.7 / spyder(刚刚更新) 如果我在终端 g=3 中写入并按回车键,我会在变量资源管理器中得到一个名为 g 的变量,如果我说 GA=3,变量资源管理器中什么也不会出现,但是如果我写 GA在终端中,变量在那里。我不知道这里发生了什么。只有当变量名有多个大写字母时才会发生。

来自他们的 github issues

For example entering the following at the commandline: TESTVAR = 2 will not show up in the workspace, although testvar = 2 will show up.

That's because there is an option to hide this kind of variable which should be (according to Python official guidelines) a global variable in an imported module (imported with the non-recommended statement "from foobar import *". Anyway to show these variables, just tick the option "show upper case [something]" (context menu)

因此,在变量资源管理器右侧的垂直栏中有一个选项图标,允许您enable/disable 大写变量。

注意:根据 PEP-8,“常量通常在模块级别上定义,并且全部用大写字母和下划线分隔单词。示例包括 MAX_OVERFLOW 和 TOTAL”。可能正是 Spyder 遵循的这个约定导致了您观察到的行为。