1
我想根據某些條件更改字典的值。如何將值列表分配給列表元素
mydic = {"10": [1, 2, 3], "20": [2, 3, 4, 7]}
key = mydic.keys()
val = mydic.values()
aa = [None] * len(key)
for i in range(len(key)):
for j in range(len(val[i])):
if val[i][j] <= 5:
aa[i][j] = int(math.ceil(val[i][j]/10))
else:
aa[i][j] = "f"
錯誤:
TypeError: 'NoneType' object does not support item assignment
非常感謝! – Franco 2014-11-23 19:53:12