python中的map()函数详解
2019-04-02 15:56
323 查看
map()函数
map(func, *iterables) --> map object Make an iterator that computes the function using arguments from each of the iterables. Stops when the shortest iterable is exhausted.
有道翻译结果:
”“”
map(func, *iterables)——> map对象
创建一个迭代器,使用来自的参数计算函数
每个迭代器。当最短的迭代器耗尽时停止。
”“”
作用
返回一个迭代器,对iterable的每个项应用function,生成结果。
因为返回值是一个迭代器所以直接打印map()的结果会出现这样的<map object at 0x00000112F878BE80>这是一个map对象
想要输出结果接着往下看
使用for循环遍历输出
num = ['1', '2', '3'] nums = map(lambda x:int(x),num) for i in nums: print(i,end=" ")
输出结果为:1 2 3
使用list()转列表输出
num = ['1', '2', '3'] print(list(map(lambda x: int(x), num))) ··· 输出结果为: [1, 2, 3]
相关文章推荐
- python3中的map函数详解
- python基础--map函数详解
- hive之Python UDF函数操作map数据 详解 全是干货
- 详解Python map函数及Python map()函数的用法
- Python中 map()函数的用法详解
- python map函数用法详解
- Python的map()函数 详解
- Python的hasattr() getattr() setattr() 函数使用方法详解
- 对Python实现累加函数的方法详解
- 对Python中map()函数的理解
- Python self参数 & 函数详解
- python zip()函数用法详解
- Python之map()和reduce()函数。
- python获取系统时间(时间函数详解)
- python函数参数详解
- 详解Python中open()函数指定文件打开方式的用法
- Python学习 Day 5 高阶函数 map/reduce filter sorter 返回函数 匿名函数 装饰器 偏函数
- python函数工具之filter,map及reduce
- 010 python函数参数的详解
- Python---高级函数map, filter, zip, enumerate等的用法