map(function, sequence) :对sequence中的item依次执行function(item),见执行结果组成一个List返回:

>>> lt = range(10)
>>> lt
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> def Pow(x):
...     return pow(x,2)
... 
>>> map(Pow,lt)
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
>>> 

 

相关文章:

  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2021-09-10
  • 2022-12-23
猜你喜欢
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
  • 2021-11-15
  • 2022-01-06
相关资源
相似解决方案