lst1 = [0] * 10
lst1 = [0 for _ in range(10)]
lst3 = list(map(lambda x: 0, range(10)))
解析:lst3 = list(map(lambda x: 0, range(10)))
- 定义函数
lambda x: 0
。接收参数x,返回 0. - map(function, iterable, …) ,map将序列中的参数,一次传入function中调用返回迭代器
- 使用list() 接收迭代器,将其装换为 list