【发布时间】:2018-02-27 19:11:04
【问题描述】:
我有一个defaultdict(list) 的:
d_int = defaultdict(type, {0: [1,2,3,4,5], 1: [6,7,8,9,10], 2: [11,12,13,14,15]})
有没有一种pythonic方法可以将每个列表中的每个n元素保存到一个新数组中,所以我有这样的东西?:
a = [1,6,11]
b = [2,7,12]
c = [3,8,13]
d = [4,9,14]
e = [5,10,15]
【问题讨论】:
-
迭代字典的键,就像使用任何字典一样。这就是使用字典的 Pythonic 方式。
-
type不是defaultdict的有效default_factory参数
标签: python numpy dictionary collections defaultdict