Python基础 · 免费预览
推导式
用一个可读的表达式,从现有数据一次性构建新的列表、字典和集合,循环可以省掉。
1. Overview
Overview
2. Building Lists from Lists
Building Lists from Lists
3. Filtering with Conditions
Filtering with Conditions
4. Dictionary and Set Comprehensions
Dictionary and Set Comprehensions
5. Keeping It Readable
Keeping It Readable
6. Square the Odds
Square the Odds
7. Length Filter
Length Filter