更新时间:2022-12-12 13:23:44
您可以使用 zip()
:
You can use zip()
:
In [23]: lis = [1,7,8,4,5,3]
In [24]: for x, y in zip(lis, lis[1:]):
....: print x, y # prints the adjacent elements
# do something here
....:
1 7
7 8
8 4
4 5
5 3