目前我有以下列表:Python:如何获得列表中的某些内容?
>>> a = list()
>>> b = [1, 2, 3]
>>> c = [4,5,6]
>>> d = [7, 8]
>>> a.append(b)
>>> a.append(c)
>>> a.append(d)
>>> del b, c, d
>>> print a
[[1, 2, 3], [4, 5, 6], [7, 8]]
- 欲获得关于b,c和d中的第一项(值1,4和7)。我怎么能在一行代码中做到这一点?
- 我想获得b,c和d上的剩余项目(值2,3,5,6和8)。我怎么能在一行代码中做到这一点?
类似'zip(b,c)[0]'或者zip(* a)[0]'? – 2013-02-25 10:42:39
拉链完美无瑕。谢谢 – Winston 2013-02-25 10:49:25
但是第二个呢?谢谢 – Winston 2013-02-25 11:03:13