【发布时间】:2021-04-17 12:29:50
【问题描述】:
我有一个lat、lon 和alt 的组合列表,按如下所示的顺序排列,现在我想将列表分为三部分,第一部分为lat,第二部分为lon,第三部分为alt。
coords = [48.92504247289378, 9.147973368734435, 29707, 48.92504291087322, 9.147998449546572, 29707, 48.9250463088055, 9.148013780873235, 29707, 48.92505484289239, 9.148021595289876, 29707, 48.925070689333246, 9.148024125370592, 29707]
#list format = [lat,lon,alt,lat,lon,alt.....]
例外输出:
lat = [48.92504247289378,48.92504291087322,48.9250463088055....]
lon = [9.147973368734435,9.147998449546572, 9.148013780873235...]
alt = [29707,29707,29707,...]
我试过了:
Split a python list into other "sublists" i.e smaller lists
Python: Split a list into sub-lists based on index ranges
Split a list into parts based on a set of indexes in Python
还有其他一些解决方案,但都没有奏效。
谁能帮我得到预期的输出?
【问题讨论】:
标签: python python-3.x list