当需要使用for循环来生成一个新列表时,可用到列表推导式。举个例子: squared = [] for x in range(10): squared.append(x**2)
可以使用列表推导式来简化它: squared = [x**2 for x in range(10)]
https://eastlakeside.gitbooks.io/interpy-zh/content/Comprehensions/list-comprehensions.html