1:list函数可以将其他类型转成list.
print(list(range(0, 10)))
2: list函数把元组转成list
t = (1, 3, 3, 5)
print(list(t))
3:range可以一个参数,两个参数,三个参数
for c in range(5): print(c) print("*" * 20) for c in range(2, 7): print(c) print("*" * 20) for c in range(0, 20, 4): print(c)
result:
0 1 2 3 4 ******************** 2 3 4 5 6 ******************** 0 4 8 12 16