lambda表達式返回一個函數對象
app
map(function,sequence),把sequence中的值逐個傳給function,返回一個包含函數執行結果的listide
例子:函數
squares = list(map(lambda x: x**2, range(10)))spa
squares值是對象
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
至關於:it
squares = [x**2 for x in range(10)]
也至關於:io
>>> squares = []>>> for x in range(10): ... squares.append(x**2)