时间:2021-01-16 12:30:37 | 栏目:Python代码 | 点击:次
我就废话不多说了,直接上代码吧!
第一种
def test1(): l = [] for i in range(1000): l = l + [i]
第二种(append )
def test2(): l = [] for i in range(1000): l.append(i)
第三种(列表推导式)
def test3(): l = [i for i in range(1000)]
第四种(list )
def test4(): l = list(range(1000))