Python语法系列博客 · 第9期[特别字符] 函数参数进阶:*args、**kwargs 与参数解包技巧
上一期小练习解答(第8期回顾)✅ 练习1:整数转字符串列表
nums =
str_list = list(map(str, nums))
✅ 练习2:筛选回文字符串
words = ["madam", "hello", "noon", "python"]
palindromes = list(filter(lambda x: x == x[::-1], words))
✅ 练习3:使用 reduce 计算乘积
from functools import reduce
product = reduce(lambda x, y: x * y, )# 24
✅ 练习4:lambda 表达式计算 x² + 2x + 1
quad = lambda x: x**2 + 2*x + 1
result = quad(3)# 16
本期主题:函数参数进阶
页:
[1]