随心一记

一二三四五,上山打老鼠


  • 首页

  • 归档

  • 标签
ywcsb

ywcsb

游戏可以不玩,小说不能不看。

153 日志
3 分类
42 标签
RSS
GitHub 知乎 随心一记
Links
  • 随心一记
  • 追梦人物的
  • MSDN

Python map函数

发表于 2019-01-26 | 阅读 821 | 分类于 Python |
#!/usr/bin/env python3
# -*-coding:utf-8-*-
# date:     2018/5/14
__author__ = 'Bing'

LI = [11, 22, 33, 44, 55, 66]


# def f(args):
#     result = []
#     for i in args:
#         result.append(100+i)
#     return result
#
#
# print(f(LI))

# map(函数,可迭代的对象(可以for循环的东西))
def f2(a):
    return a + 100


result = map(f2, LI)
print(list(result))


result2 = map(lambda a: a + 100, LI)
print(list(result2))

将函数返回值添加到结果中

觉得不错,支持一下!
geerniya WeChat Pay

微信打赏

geerniya Alipay

支付宝打赏

# Python # 脚本
Python filter函数
Linux运维跳槽必备的40道面试精华题

发表评论

共 0 条评论

    暂无评论
© 2018 - 2022 ywcsb
冀ICP备17022045号-1
Supported by 腾讯云