假设我有一个列表:
theList = [1, -3, 9, -7, 2, 5, 2, -4, -5]
您可以使用
theList[start:end+1]
for item in theList[2:7]: print(item)