The map function is an important function in Python, inspired by functional programming, and is explained in the official Python documentation:
map(function, iterable, ...)
Return an iterator that applies function to every item of iterable, yielding the results. If additional iterable arguments are passed, function must take that many arguments and is applied to the items from all iterables in parallel. With multiple iterables, the iterator stops when the shortest iterable is exhausted.
That is, the map function receives the first parameter for a function, can be a system function such as float, or def defined function, or lambda defined function can be.
As a simple example, the following example is displayed correctly under Python 2.7:
ls = [1,2,3] rs = map(str, ls) # Print results ['1', '2', '3'] lt = [1, 2, 3, 4, 5, 6] def add(num): return num + 1 rs = map(add, lt) print rs #[2,3,4,5,6,7]
But under Python 3 we type:
ls=[1,2,3] rs=map(str,ls) print(rs)
The display is instead:
<map at 0x3fed1d0>
Instead of the result we want, which is some new changes that happened under Python 3, we need to write it this way if we want to get the result we need:
ls=[1,2,3] rs=map(str,ls) print(list(rs))
This displays the result that we want to see. This is helped a bit in Chapter 10 of Machine Learning in Action.
The above article to solve the problem of displaying the map function under Python3 is all that I have shared with you, I hope to give you a reference, and I hope you will support me more.