天天上头条 发表于 2019-4-8 17:37:46

python内置方法,map

map(function, iterable, ...)

function -- 函数
iterable -- 一个或多个序列

def square(x) :            # 计算平方数
...   return x ** 2
map(square, )   # 计算列表各个元素的平方


map(lambda x: x ** 2, )# 使用 lambda 匿名函数


页: [1]
查看完整版本: python内置方法,map