python内置map返回的是列表,而six.moves.map返回的是iter。
>>> map(lambda a: a*2, [1, 2, 3]) [2, 4, 6] >>> m = six.moves.map(lambda a: a*2, [1, 2, 3]) >>> type(m) <type 'itertools.imap'> >>> next(m) 2 >>> next(m) 4 >>> m.next() 6
python内置map返回的是列表,而six.moves.map返回的是iter。
>>> map(lambda a: a*2, [1, 2, 3]) [2, 4, 6] >>> m = six.moves.map(lambda a: a*2, [1, 2, 3]) >>> type(m) <type 'itertools.imap'> >>> next(m) 2 >>> next(m) 4 >>> m.next() 6