map 函数

# 求x的平方的列表
l = list(map(lambda x: x*x, [1, 2, 3, 4]))
print(l)# [1, 4, 9, 16]

 

names = ['adam', 'LISA', 'barT']
formatted_names = list(map(lambda x: x.title(), names))
print(formatted_names)

 

posted @ 2023-07-08 21:24  胖豆芽  阅读(26)  评论(0编辑  收藏  举报