1. 建立一個空字典python
dict = {}
2. 判斷字典中有無目標索引spa
if a in dict
3. 字典中索引的值加一code
dict['a'] = dict.get('a', 0) + 1
4. 將字典寫入csv文件blog
writer = csv.writer(csvfile) for key, value in dict.items(): writer.writerow([key, value])
5. 當字典的value是一個list時候索引
if name not in task: task[name] = []