第一种 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)) 用这种方法缺点即是得到从0到n-1的数字,如果是要数字n,则要在n后面+1 分类: Python学习软件开发 标签:python3编程语言