1. Map函数
2. filter函数
numbers = generate_numbers()
filtered_numbers = filter(lambda x: x % 2 == 0, numbers)
for _ in range(5):print(next(filtered_numbers)) # 输出: 0 2 4 6 8
3. filter map 和 reduce
4. picking and unpicking
5. python 没有函数的重载, *args, **kwargs来实现同样的功能
6. init new
7. 魔术方法
8. python编码规范
9. python线程池
from concurrent.futures import ThreadPoolExecutordef task(n):return n * nwith ThreadPoolExecutor(max_workers=5) as executor:future1 = executor.submit(task, 1)future2 = executor.submit(task, 2)future3 = executor.submit(task, 3)result1 = future1.result()result2 = future2.result()result3 = future3.result()print(result1, result2, result3)
10. 匿名函数
def multiply():return [lambda x, i=i: i * x for i in range(4)]
print([m(10) for m in multiply()])
[0, 10, 20, 30]def multiply():return [lambda x: i * x for i in range(4)]
[30, 30, 30, 30]