python3 map

It has a large difference map and functional map of python3 python2 of
python2:
like this
. 1 >>> A = [1,3,5,7,9]
2 >>> B = [2,4,6,8, 0]
. 3 >>> map (the lambda X, Y: X + Y, a, B)
. 4 [. 3,. 7,. 11, 15,. 9]
is important to map the return value is a List
to python3:
Data = [[. 1 ,. 3,. 4], [2,. 3,. 5], [. 1, 2,. 3,. 5], [2,. 5]]
Print (Data)
[[. 1,. 3,. 4], [2,. 3,. 5] , [. 1, 2,. 3,. 5], [2,. 5]]
Data = Map (SET, Data)
Print (Data)
<Map Object AT 0x000002EF0C5202E8>
Map object returned is an address (iterator), not real data
but we can use the list (map (x, y) ) returns a list object
we have to note iterator problem:
Print (list (data))
[{. 1,. 3,. 4}, {2,. 3,. 5}, { 1, 2, 3, 5}, {2, 5}]
results ----------------- first variable may return normally required

Print (List (the Data))
[]
----------------- second pass was empty, because the time has come on the tail

So if we want to take advantage of multiple map objects returned. Best to start saving
as list1 = list (map (x, y))
like list1 operation and subsequent use.

Published 48 original articles · won praise 23 · views 1314

Guess you like

Origin blog.csdn.net/qq_37724465/article/details/104161614