record = {'example' : 0}
for i in range(0,10):
record['example'] = record['example']所对应的 value+1
关键问题在于「 record['example']所对应的 value 」该怎么写?
1
loveersoldier 2016-09-05 16:06:52 +08:00
record['example'] += 1
|
2
NaVient 2016-09-05 17:12:45 +08:00
record['example']就是对应的 value 啊
|
3
beviniy 2016-09-06 13:37:52 +08:00
from itertools import Counter
|
4
tumbzzc 2016-09-06 19:22:28 +08:00
突然觉得很囧
|
5
wind3110991 2016-09-12 23:19:42 +08:00
record = {'example' : 0}
for i in range(0,10): record['example'] = record['example'] + 1 print record['example'] |
6
romanticbao 2016-09-17 02:56:58 +08:00
record = {}
DEFAULT_VALUE = 0 for item in data_list: record[item] = record.get(item, DEFAULT_VALUE) + 1 |