python RuntimeError: dictionary changed size during iteration

前端 未结 5 1961
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 12:32

I have obj like this

{hello: \'world\', \"foo.0.bar\": v1, \"foo.0.name\": v2, \"foo.1.bar\": v3}

It should be expand to

{         


        
5条回答
  •  一个人的身影
    2020-11-30 13:20

    Like the message says: you changed the number of entries in obj inside of expandField() while in the middle of looping over this entries in expand.

    You might try instead creating a new dictionary of the form you wish, or somehow recording the changes you want to make, and then making them AFTER the loop is done.

提交回复
热议问题