python3中map函数的改动
来源:互联网 发布:爆破数据库密码 编辑:程序博客网 时间:2024/06/09 19:04
其实在What's new in python3 中都写了。
map() and filter() return iterators. If you really need a list and the input sequences are all of equal length, a quick fix is to wrap map() in list(), e.g. list(map(...)), but a better fix is often to use a list comprehension (especially when the original code uses lambda), or rewriting the code so it doesn’t need a list at all. Particularly tricky is map() invoked for the side effects of the function; the correct transformation is to use a regular for loop (since creating a list would just be wasteful).
大意就是,不会返回list而是返回iterator了。这样可以懒惰计算balabala。可以list(map()..)来解决,不过推荐使用列表解析,或者不用列表。
0 0
- python3中map函数的改动
- Python3中map函数的问题
- 转载-Python3中map函数的问题
- Python3中cmp函数和raw_input的改动(第一篇博客)
- Python3的新改动
- python2.x中函数在python3.x中的改动方法
- python2.x中函数在python3.x中的改动方法
- python3中map的问题
- Python3.0的新改动
- Python3.0的新改动
- Python3.0的新改动
- symbian中CSmsSettings几个函数的改动
- python2和python3 map函数的区别
- python3的map函数显示问题
- Python3.4中filter函数,map函数和reduce函数
- Python3.4中filter函数,map函数和reduce函数
- Python3.4中filter函数,map函数和reduce函数
- python3 map函数
- Delphi 操作 SQL数据库
- Java 线程池学习
- ARM异常处理解析
- Hadoop0.20.203 完全分布式配置
- 【算法-排序之三】插入排序
- python3中map函数的改动
- FragmentPagerAdapter
- js传递参数给php有乱码解决方案
- Git 推送和删除远程标签
- iOS 系列译文:Mach-O 可执行文件
- FragmentPagerAdapter
- 2014-03-14周五工作日志:HeapAlloc与malloc的区别
- Hadoop0.20.203.0+Hbase0.90.4完全分布式配置
- KVC和KVO