我怎样才能转变
[(212, u'comment', 0L), (205, u'main', 0L)]
进入这个?
(0L, 0L)
>>> data = [(212, u'comment', 0L), (205, u'main', 0L)]
>>> tuple(x[2] for x in data)
(0L, 0L)
或者其他方法...
>>> zip(*data) # just showing what zip(*data) does
[(212, 205), (u'comment', u'main'), (0L, 0L)]
>>> zip(*data)[2]
(0L, 0L)
使用itertools.imap()
和operator.itemgetter()
...
>>> from itertools import imap
>>> from operator import itemgetter
>>> tuple(imap(itemgetter(2), data))
(0L, 0L)