有什么想法可以创建一个这种类型的列表吗?
cities = [
('Aberdeen, Scotland', '5:00 p.m.', 57.15, -2.15),
('Adelaide, Australia', '2:30 a.m.', -34.916667, 138.6),
('Algiers, Algeria', '6:00 p.m.', 36.833333, 3),
('Amsterdam, Netherlands', '6:00 p.m.', 52.366667, 4.883333),
('Ankara, Turkey', '7:00 p.m.', 39.916667, 32.916667),
('Asuncion, Paraguay', '1:00 p.m.', -25.25, -57.666667),
('Athens, Greece', '7:00 p.m.', 37.966667, 23.716667),
('Auckland, New Zealand', '5:00 a.m.', -36.866667, 174.75),
('Bangkok, Thailand', 'midnight', 13.75, 100.5),
('Barcelona, Spain', '6:00 p.m.', 41.383333, 2.15),
('Beijing, China', '1:00 a.m.', 39.916667, 116.416667)
]我将获取一个NMEA字符串,并尝试将其解析为一个格式正确的列表,以便SimpleKML Python库创建坐标。到目前为止,我尝试的所有内容都创建了坐标0,0,1。
谢谢
发布于 2015-04-18 09:20:36
去掉这一点,使用python的zip内置。
>>> cities = ['testcity', 'testcity2', 'testcity3']
>>> times = ['5:00 pm', '4:00 pm', '3:00 pm']
>>> lat = [57.15, -34.916667, 36.8333]
>>> lon = [110.345, -23.765, 41.38333]]
>>> lon = [110.345, -23.765, 41.38333]
>>> new = zip(cities, times, lat, lon)
>>> print new
[('testcity', '5:00 pm', 57.15, 110.345), ('testcity2', '4:00 pm', -34.916667, -23.765), ('testcity3', '3:00 pm', 36.8333, 41.38333)]https://stackoverflow.com/questions/29711762
复制相似问题