[Python] python里的map函数用法 →→→→→进入此内容的聊天室

来自 , 2020-05-08, 写在 Python, 查看 128 次.
URL http://www.code666.cn/view/836a0dcb
  1. #map function
  2. #basic syntax
  3. def mul2(x):
  4.   return x*2
  5. testList = [1,2,3,4]
  6. print map(mul2,testList)
  7. print map(lambda x: x*3,testList)
  8. #map function that has two arguments
  9. def mul(x,y):
  10.   return x*y
  11. print map(mul,[1,2,3,4],testList)
  12. #//python/4450

回复 "python里的map函数用法"

这儿你可以回复上面这条便签

captcha