map函数形参为一个函数和一个迭代对象
给定一个列表,实现加1
L = [1, 2, 3, 4, 5] res = map(lambda x:x+1, L) print(list(res)) # 不使用map函数,实现的效果是一模一样的 def add_test(x): return x+1 def map_test(func, array): temp = [] for i in array: res = func(i) temp.add(res) return temp res = map_test(add_test, L) print(res)
继续阅读与本文标签相同的文章
上一篇 :
Python精华之函数
-
SpringBoot2 整合 ElasticSearch框架,实现高性能搜索引擎
2026-05-19栏目: 教程
-
大神引路:新手云大使入门导引
2026-05-19栏目: 教程
-
一行命令导致的数据丢失,阿里工程师是如何恢复的?
2026-05-19栏目: 教程
-
二层、三层、四层交换机的区别!!
2026-05-19栏目: 教程
-
阿里云安全肖力:云原生安全定义下一代安全架构
2026-05-19栏目: 教程
