1、map可以根据提供的函数对指定序列做映射,它接受一个函数f和一个list,并通过把函数f以此作用在list上的每个元素,然后返回一个新的list,map函数的入参也可以是多个.注意这个函数一定要有返回值。不然就会返回新的list 类似[None, None, None, None, None, None, None, None, None]
2、Python2 与 Python3 的使用区别:
注意:在python2中可以直接使用map(fun,a)
,但是在python3中会显示<map at 0xc8c9320>
,需要添加`list()
才能实现2的功能。
如c = list(map(fun,a))