#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @File : 匿名函数.py @Author : lichao @Date : 2024/12/11 21:11 @Software : PyCharm """ # 一个匿名函数的使用场景 student_list = [ {'name': 'Jerry', 'age': 21}, {'name': 'Tom', 'age': 20}, {'name': 'Mickey', 'age': 22} ] sorted_list = sorted(student_list, key=lambda x: x['age']) print(sorted_list)