def test1():
l = []
for i in range(10):
l = l + [i]
print(l)
def test2():
l = []
for i in range(10):
l.append(i)
print(l)
def test3():
l = [i for i in range(10)]
print(l)
def test4():
l = list(range(10))
print(l)
输出:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]