双重循环+遍历中修改字典//RuntimeError: dictionary changed size during iteration

2017-07-27 17:03:22 +08:00
 xylsmmmmmmmm3
2252 次点击
所在节点    Python
3 条回复
xylsmmmmmmmm3
2017-07-27 17:04:32 +08:00
shuzi = {'1': {'end': 3247341040L, 'star': 3247341040L}, 2: {'end': 1033039063, 'star': 1033039056},3:{'end':111,'star':2222222222222}}
for key1 in shuzi.keys():
print key1
if not shuzi.has_key(key1):
break
for key2 in shuzi:

"""
有没有更好得解决方法?
xylsmmmmmmmm3
2017-07-27 17:05:16 +08:00
shuzi = {'1': {'end': 3247341040L, 'star': 3247341040L}, 2: {'end': 1033039063, 'star': 1033039056},3:{'end':111,'star':2222222222222}}
for key1 in shuzi.keys():
if not shuzi.has_key(key1):
break
for key2 in shuzi:
zhjits
2017-07-27 17:09:21 +08:00

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/378410

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX