danjialan

导航

 

2016年11月22日

摘要: import collections s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)] # defaultdict d = collections.defaultdict(list) for k, v in s: d[k].append(v) # Use dict and setdefault... 阅读全文
posted @ 2016-11-22 20:19 danjialan 阅读(136) 评论(0) 推荐(0) 编辑