我在以下代码中遇到了 def load() 问题:
def load():
claim = {}
data = open("claim.DB").read().split("\n")
for a in data:
claimDB[a.split(",")[0]] = a.split(",")[1:]
claim.claimDB = claimDB
出于某种原因,这条线在def load():
claimDB[a.split(",")[0]] = a.split(",")[1:]
导致此问题:
dictionary changed size during iteration
并且每次你做 claim.load() 时都让 dict 这样做:
{'': [], 'asl97': ['charles', 'donboricua'], 'a': ['s', 'l', '9', '7', 'c', 'h', 'a', 'r', 'l', 'e', 's']}
{'':[],'a':['s','','','l','','','9','','','7','',' ','c','','','h','','','a','','','r','','','l','',' ', 'e', '', '', 's']}