map的使用(自增)ret = map(lambda x : x+100 if x % 2 == 1 else x - 100, [1,2,3,4,5])

Posted 失落的黎明

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了map的使用(自增)ret = map(lambda x : x+100 if x % 2 == 1 else x - 100, [1,2,3,4,5])相关的知识,希望对你有一定的参考价值。

1 #!/usr/bin/env python
2 ret = map(lambda x : x+100 if x % 2 == 1 else x - 100, [1,2,3,4,5])
3 print(ret)
4 for i in ret :
5     print(i)

 

以上是关于map的使用(自增)ret = map(lambda x : x+100 if x % 2 == 1 else x - 100, [1,2,3,4,5])的主要内容,如果未能解决你的问题,请参考以下文章

16python的map函数,filter函数,reduce函数

[Java基础]让Map value自增

python-高阶函数(map,reduce,filter)

关于小程序使用map组件,标记markers时报错误(ret is not defined)

Python map函数

filter函数和map函数