n=[1,2,3,4,5,6,7,8,9,10]
print(n)
n=list(range(1,11))
print(n)
n=[i for i in range(1,11)]
print(n)
n=[]
for i in range(1,11):
n.append(i)
print(n)
# 结果都是:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
python | 将指定范围内的数字存放在列表里并输出(4种方法
最新推荐文章于 2024-08-19 03:21:15 发布