我有一个包含按元组排序的坐标的列表:
list = [(316852,4.99246e+06), (316858,4.99244e+06), (316880,4.99246e+06), (316863,4.99248e+06), (316852,4.99246e+06)]
我希望按组2得到它的元素。预期的结果是这样的:
(316852,4.99246e+06), (316858,4.99244e+06)
(316858,4.99244e+06), (316880,4.99246e+06)
(316880,4.99246e+06), (316863,4.99248e+06)
(316863,4.99248e+06), (316852,4.99246e+06)
关于如何获得这个的任何想法?
答案 0 :(得分:1)
这样的东西?
list = [(316852,4.99246e+06), (316858,4.99244e+06), (316880,4.99246e+06), (316863,4.99248e+06), (316852,4.99246e+06)]
for x in range(0, len(list)-1):
print(list[x], list[x+1])
答案 1 :(得分:-1)
你可以试试这个:
print([list[i:i+2] for i in range(0,len(list),2)])