1.列表取值
(1)每次取3个
a = [1, 2, 3, 4, 5, 6, 7]
step = 3
for i in range(0, len(a), step):
print(a[i:i+step])
打印结果:
[1, 2, 3]
[4, 5, 6]
[7]
原文地址:https://blog.51cto.com/fengjicheng/2462218
时间: 2024-10-11 16:04:23
1.列表取值
a = [1, 2, 3, 4, 5, 6, 7]
step = 3
for i in range(0, len(a), step):
print(a[i:i+step])
打印结果:
[1, 2, 3]
[4, 5, 6]
[7]
原文地址:https://blog.51cto.com/fengjicheng/2462218