lambda函数

Dreamer_Luo edited 3 年,3 月前

匿名函数lambda的定义
1. 无参数
f = lambda : value
2. 有参数
f = lambda x,y: x * y

users = [
{“name”: “dewei”},
{“name”: “xiaomu”},
{“name”: “abc”}
]

users.sort(key = lambda x: x[“name”])

Comments