【发布时间】:2021-03-12 03:39:02
【问题描述】:
下面是我的代码的一个极其简化的版本:
foo = 0
bar = 0
baz = 0
while True:
answer = input('Type an input here: ')
print('And do something with it here.')
if answer == 'okay':
foo += 1
else:
bar += 1
baz += 1
print(foo, bar, baz)
当我保存这个时,VSCode 给我一个警告说:
常量名称“foo”不符合 UPPER_CASE 命名风格
常量名称“foo”不符合 UPPER_CASE 命名风格
常量名称“foo”不符合 UPPER_CASE 命名风格
我的问题是“+= 1”是否会影响变量是否应该是常量?我认为“+= 1”会导致变量在变量更改时不是常量,但 VSCode 告诉我不是这样。
【问题讨论】:
标签: python python-3.x visual-studio-code constants