在迭代字典上更新字典后,只保留最后一个迭代对。
样本:
# DICTIONARY PROBLEM
class Dict_ator(object):
def __init__(self, str, int):
self.string = str
self.integer = int
boogeyman = []
i = 1
for char in "boogeyman" :
boogeyman.append( Dict_ator(char, i) )
i += 1
dictonary = {}
for b in boogeyman :
dictonary.update( s = b.string, i = b.integer )
我做错了什么?