[英]How to convert a float list to a tuple list by pair?
假設列表的長度總是偶數,轉換以下列表的最佳方法是什么:
points = [[1437.8552278820375, 1187.3458445040214, 1084.396782841823, 1245.6836461126006, 1104.9865951742627, 1430.9919571045577, 1458.4450402144773, 1307.4530831099196]]
到元組列表,例如:
points = [(1437.8552278820375, 1187.3458445040214), (1084.396782841823, 1245.6836461126006), (1104.9865951742627, 1430.9919571045577), (1458.4450402144773, 1307.4530831099196)]
points = zip(points[0][::2], points[0][1::2])
list(points)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.