#create a list l = [("x", 1), ("x", 2), ("x", 3), ("y", 1), ("y", 2), ("z", 1)] d = {} for a, b in l: d.setdefault(a, []).append(b) print (d)
python 元组列表转为字典
猜你喜欢
转载自www.cnblogs.com/sea-stream/p/9944986.html
今日推荐
周排行