map(function, sequence) :对sequence中的item依次执行function(item),见执行结果组成一个List返回:
>>> lt = range(10) >>> lt [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> def Pow(x): ... return pow(x,2) ... >>> map(Pow,lt) [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] >>>
时间: 2024-11-16 02:36:31