From 44a7888fd02fd700e149730a90d1aca907a979b7 Mon Sep 17 00:00:00 2001 From: "yinjun.chen1" Date: Mon, 18 May 2026 17:29:42 +0800 Subject: [PATCH] no message --- pythonProject/内置函数/lambda/1.py | 4 ++++ pythonProject/内置函数/lambda/2.py | 4 ++++ pythonProject/内置函数/lambda/3.py | 3 +++ pythonProject/内置函数/lambda/4.py | 4 ++++ 4 files changed, 15 insertions(+) create mode 100644 pythonProject/内置函数/lambda/1.py create mode 100644 pythonProject/内置函数/lambda/2.py create mode 100644 pythonProject/内置函数/lambda/3.py create mode 100644 pythonProject/内置函数/lambda/4.py diff --git a/pythonProject/内置函数/lambda/1.py b/pythonProject/内置函数/lambda/1.py new file mode 100644 index 0000000..a366cff --- /dev/null +++ b/pythonProject/内置函数/lambda/1.py @@ -0,0 +1,4 @@ +# 简单加法 +add =lambda x,y:x+y +print(add(100,200)) +print("------") diff --git a/pythonProject/内置函数/lambda/2.py b/pythonProject/内置函数/lambda/2.py new file mode 100644 index 0000000..136562a --- /dev/null +++ b/pythonProject/内置函数/lambda/2.py @@ -0,0 +1,4 @@ +# 与map在一块使用 +numbers = [1,2,3,4] +a= list(map(lambda x:x*2,numbers)) +print(a) \ No newline at end of file diff --git a/pythonProject/内置函数/lambda/3.py b/pythonProject/内置函数/lambda/3.py new file mode 100644 index 0000000..08f879e --- /dev/null +++ b/pythonProject/内置函数/lambda/3.py @@ -0,0 +1,3 @@ +numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +a= list(filter(lambda x: x % 2 == 0, numbers)) +print(a) \ No newline at end of file diff --git a/pythonProject/内置函数/lambda/4.py b/pythonProject/内置函数/lambda/4.py new file mode 100644 index 0000000..065866f --- /dev/null +++ b/pythonProject/内置函数/lambda/4.py @@ -0,0 +1,4 @@ +students = [('Alice', 85), ('Bob', 90), ('Charlie', 78)] +sorted_students = sorted(students, key=lambda x: x[1]) +print(sorted_students) +# 按成绩排序: [('Charlie', 78), ('Alice', 85), ('Bob', 90)] \ No newline at end of file