网站首页 > 基础教程 正文
map 函数主要的内容是把新函数 mul 的内容一一映射到数组 n 中的每个元素上。
def mul(x):
return x*x
n=[1,2,3,4,5]
res=list(map(mul,n))
print(res)
list(map(mul,n))
list 把映射的结果再变成数组 list 。
sum(map(mul,n))
sum 把映射的结果相加求和。
猜你喜欢
- 2024-11-02 Python函数式编程之map/reduce/filter进阶
- 2024-11-02 Python中map函数的奇淫技巧:优化你的编程体验
- 2024-11-02 python内置函数map/reduce/filter
- 2024-11-02 Python 内置函数与匿名函数 python匿名内部类
- 2024-11-02 第八篇:Python中函数介绍 python中的各种函数
- 2024-11-02 「每天3分钟学Python」Python中的 Map 和 Reduce
- 2024-11-02 Python中starmap有什么用的? python中start用法
- 2024-11-02 详解Python中的map、lambda和apply用法
- 2024-11-02 Python编程技巧:如何用Map, Filter, Reduce代替For循环?
- 2024-11-02 python lambda函数与map()、filter()、reduce()函数用法
- 最近发表
- 标签列表
-
- jsp (69)
- gitpush (78)
- gitreset (66)
- python字典 (67)
- dockercp (63)
- gitclone命令 (63)
- dockersave (62)
- linux命令大全 (65)
- pythonif (86)
- location.href (69)
- dockerexec (65)
- tail-f (79)
- queryselectorall (63)
- location.search (79)
- bootstrap教程 (74)
- 单例 (62)
- linuxgzip (68)
- 字符串连接 (73)
- html标签 (69)
- c++初始化列表 (64)
- mysqlinnodbmyisam区别 (63)
- arraylistadd (66)
- mysqldatesub函数 (63)
- window10java环境变量设置 (66)
- c++虚函数和纯虚函数的区别 (66)