0

Any ideas how to create a list of this type?

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)
]

I'm taking a NMEA string and trying to parse it into a properly formatted list for the SimpleKML Python library to create coordinates. Everything I've tried thus far creates coordinates that plot as 0,0,1.

Thanks

4

1 回答 1

0

从头开始,使用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)]
于 2015-04-18T01:20:36.100 回答