python中map的用法,pythonmap用法,#范例1:>>> pri


#范例1:>>> print map(abs, [-5,7,-12] )[5, 7, 12]#范例2:>>> print [abs(i) for i in [-5,7,-12]][5, 7, 12]#范例3:>>> def myfunction(value):...     return value*10+1...>>> print map(myfunction, [1,2,3,4] )[11, 21, 31, 41]>>>#范例4:>>> print map(max, [4,5,6], [1,2,9] )[4, 5, 9]#范例5:>>> [ max(4,1), max(5,2), max(6,9) ][4, 5, 9]

评论关闭