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函数
python-高阶函数(map,reduce,filter)