1.在字典遍历过程中修改字典元素,报错 RuntimeError: dictionary changed size during iteration
错误代码:
for i in phone:
i = int(i)
for key in dict_phone.keys():
if key == i:
print(dict_phone.pop(key,'ss'))
改正
for i in phone:
i = int(i)
for key in list(dict_phone.keys()):
if key == i:
print(dict_phone.pop(key,'ss'))
标签:dictionary,python,RuntimeError,phone,dict,key,size,字典
From: https://www.cnblogs.com/chentiao/p/17705543.html