且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

python更新for循环中的外部传递值

更新时间:2022-10-27 22:15:27

One workaround is to structure your data differently, for example by using:

d = {'str1': 'before', 'str2': 'before'}
for i in d:
    print d[i]
    d[i] = "after"

The important thing is that this variable is mutable (as discussed in your link).