在Python2中map函数会返回⼀个list列表,如代码:
>>> def f(x, y): return (x, y) >>> l1 = [ 0, 1, 2, 3, 4, 5, 6 ]
>>> l2 = [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ]
返回结果如下:
>>> map(f, l1, l2)
[(0, 'Sun'), (1, 'Mon'), (2, 'Tue'), (3, 'Wed'), (4, 'Thu'), (5, 'Fri'), (6, 'Sat')]
但是,在Python3中返回结果如下:
>>> map(f1, l1, l2)