看板 [ Python ]
討論串[問題]list合成dict
共 2 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓2(2推 0噓 3→)留言5則,0人參與, 最新作者aquarianboy (高 見龍)時間15年前 (2009/12/11 18:57), 編輯資訊
0
0
1
內容預覽:
用個簡單的for..in..就可以把資料塞進去囉 :). food = ['apple', 'cake', 'candy', 'coffee', 'sprout']. food_dict = {}. for f in food:. food_dict[f] = len(f). print food_

推噓1(1推 0噓 3→)留言4則,0人參與, 最新作者tacosung (taco)時間15年前 (2009/12/11 18:19), 編輯資訊
0
0
0
內容預覽:
大家好. 又來發問了. 我想要把. food = [['apple', 'cake', 'candy', 'coffee', 'sprout'], [5, 4, 5, 6, 6]]. 弄成. dict = {'apple':5, 'cake':4, 'candy':5, 'coffee':6, 's
首頁
上一頁
1
下一頁
尾頁