l = [1, 2, 3, 4, 5]
def foo(i):
    return i*i

n = map(foo, l)
print(list(n))

打印结果为 

[1, 4, 9, 16, 25]

 

相关文章:

  • 2021-10-12
  • 2021-09-05
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2021-07-07
  • 2021-12-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
相关资源
相似解决方案