小编Cos*_*547的帖子

如何更新python中for循环中的值?

假设我有一个具有以下值的变量列表

a, b, c = 1, 2, 3

Run Code Online (Sandbox Code Playgroud)

如何更新a,b,cfor 循环中的值?

我已经尝试了以下但它不起作用。

for v in (a, b, c):
    v = v + 1
Run Code Online (Sandbox Code Playgroud)

a,b,c处理后的值保持不变

print(a, b, c)
# [1] 1 2 3
Run Code Online (Sandbox Code Playgroud)

python

3
推荐指数
1
解决办法
104
查看次数

标签 统计

python ×1