· software
Python 推导式是声明式的(以及这为何重要)
两种在列表中对每个数字求平方的 Python 方法 **Version A** ```python squares = [] for num in numbers: squares.append(num ** 2) ``` **Version B** ```python squares = [num ** 2 for num in numbers] ```
两种在列表中对每个数字求平方的 Python 方法 **Version A** ```python squares = [] for num in numbers: squares.append(num ** 2) ``` **Version B** ```python squares = [num ** 2 for num in numbers] ```