工作需要,找全球主要城市的经纬度,发现百度出来的结果不是截图就是无法下载,总之不能愉快的拿来用,祭出G00gle大婶 找到这个地址 http://www.infoplease.com/ipa/A0001769.html 防止地址失效,我把表格搬运过来,附上解析表格获取十进制格式经纬度的脚本。
Latitude | Longitude | ||||
---|---|---|---|---|---|
City | ° | ‘ | ° | ‘ | Time |
Aberdeen, Scotland | 57 | 9 N | 2 | 9 W | 5:00 p.m. |
Adelaide, Australia | 34 | 55 S | 138 | 36 E | 2:30 a.m.1 |
Algiers, Algeria | 36 | 50 N | 3 | 0 E | 6:00 p.m. |
Amsterdam, Netherlands | 52 | 22 N | 4 | 53 E | 6:00 p.m. |
Ankara, Turkey | 39 | 55 N | 32 | 55 E | 7:00 p.m. |
Asunción, Paraguay | 25 | 15 S | 57 | 40 W | 1:00 p.m. |
Athens, Greece | 37 | 58 N | 23 | 43 E | 7:00 p.m. |
Auckland, New Zealand | 36 | 52 S | 174 | 45 E | 5:00 a.m.1 |
Bangkok, Thailand | 13 | 45 N | 100 | 30 E | midnight |
Barcelona, Spain | 41 | 23 N | 2 | 9 E | 6:00 p.m. |
Beijing, China | 39 | 55 N | 116 | 25 E | 1:00 a.m.1 |
Belém, Brazil | 1 | 28 S | 48 | 29 W | 2:00 p.m. |
Belfast, Northern Ireland | 54 | 37 N | 5 | 56 W | 5:00 p.m. |
Belgrade, Serbia | 44 | 52 N | 20 | 32 E | 6:00 p.m. |
Berlin, Germany | 52 | 30 N | 13 | 25 E | 6:00 p.m. |
Birmingham, England | 52 | 25 N | 1 | 55 W | 5:00 p.m. |
Bogotá, Colombia | 4 | 32 N | 74 | 15 W | 12:00 noon |
Bombay, India | 19 | 0 N | 72 | 48 E | 10:30 p.m. |
Bordeaux, France | 44 | 50 N | 0 | 31 W | 6:00 p.m. |
Bremen, Germany | 53 | 5 N | 8 | 49 E | 6:00 p.m. |
Brisbane, Australia | 27 | 29 S | 153 | 8 E | 3:00 a.m.1 |
Bristol, England | 51 | 28 N | 2 | 35 W | 5:00 p.m. |
Brussels, Belgium | 50 | 52 N | 4 | 22 E | 6:00 p.m. |
Bucharest, Romania | 44 | 25 N | 26 | 7 E | 7:00 p.m. |
Budapest, Hungary | 47 | 30 N | 19 | 5 E | 6:00 p.m. |
Buenos Aires, Argentina | 34 | 35 S | 58 | 22 W | 2:00 p.m. |
Cairo, Egypt | 30 | 2 N | 31 | 21 E | 7:00 p.m. |
Calcutta, India | 22 | 34 N | 88 | 24 E | 10:30 p.m. |
Canton, China | 23 | 7 N | 113 | 15 E | 1:00 a.m.1 |
Cape Town, South Africa | 33 | 55 S | 18 | 22 E | 7:00 p.m. |
Caracas, Venezuela | 10 | 28 N | 67 | 2 W | 1:00 p.m. |
Cayenne, French Guiana | 4 | 49 N | 52 | 18 W | 2:00 p.m. |
Chihuahua, Mexico | 28 | 37 N | 106 | 5 W | 10:00 a.m. |
Chongqing, China | 29 | 46 N | 106 | 34 E | 1:00 a.m.1 |
Copenhagen, Denmark | 55 | 40 N | 12 | 34 E | 6:00 p.m. |
Córdoba, Argentina | 31 | 28 S | 64 | 10 W | 2:00 p.m. |
Dakar, Senegal | 14 | 40 N | 17 | 28 W | 5:00 p.m. |
Darwin, Australia | 12 | 28 S | 130 | 51 E | 2:30 a.m.1 |
Djibouti, Djibouti | 11 | 30 N | 43 | 3 E | 8:00 p.m. |
Dublin, Ireland | 53 | 20 N | 6 | 15 W | 5:00 p.m. |
Durban, South Africa | 29 | 53 S | 30 | 53 E | 7:00 p.m. |
Edinburgh, Scotland | 55 | 55 N | 3 | 10 W | 5:00 p.m. |
Frankfurt, Germany | 50 | 7 N | 8 | 41 E | 6:00 p.m. |
Georgetown, Guyana | 6 | 45 N | 58 | 15 W | 1:00 p.m. |
Glasgow, Scotland | 55 | 50 N | 4 | 15 W | 5:00 p.m. |
Guatemala City, Guatemala | 14 | 37 N | 90 | 31 W | 11:00 a.m. |
Guayaquil, Ecuador | 2 | 10 S | 79 | 56 W | 12:00 noon |
Hamburg, Germany | 53 | 33 N | 10 | 2 E | 6:00 p.m. |
Hammerfest, Norway | 70 | 38 N | 23 | 38 E | 6:00 p.m. |
Havana, Cuba | 23 | 8 N | 82 | 23 W | 12:00 noon |
Helsinki, Finland | 60 | 10 N | 25 | 0 E | 7:00 p.m. |
Hobart, Tasmania | 42 | 52 S | 147 | 19 E | 3:00 a.m.1 |
Hong Kong, China | 22 | 20 N | 114 | 11 E | 1:00 a.m.1 |
Iquique, Chile | 20 | 10 S | 70 | 7 W | 1:00 p.m. |
Irkutsk, Russia | 52 | 30 N | 104 | 20 E | 1:00 a.m. |
Jakarta, Indonesia | 6 | 16 S | 106 | 48 E | midnight |
Johannesburg, South Africa | 26 | 12 S | 28 | 4 E | 7:00 p.m. |
Kingston, Jamaica | 17 | 59 N | 76 | 49 W | 12:00 noon |
Kinshasa, Congo | 4 | 18 S | 15 | 17 E | 6:00 p.m. |
Kuala Lumpur, Malaysia | 3 | 8 N | 101 | 42 E | 1:00 a.m.1 |
La Paz, Bolivia | 16 | 27 S | 68 | 22 W | 1:00 p.m. |
Leeds, England | 53 | 45 N | 1 | 30 W | 5:00 p.m. |
Lima, Peru | 12 | 0 S | 77 | 2 W | 12:00 noon |
Lisbon, Portugal | 38 | 44 N | 9 | 9 W | 5:00 p.m. |
Liverpool, England | 53 | 25 N | 3 | 0 W | 5:00 p.m. |
London, England | 51 | 32 N | 0 | 5 W | 5:00 p.m. |
Lyons, France | 45 | 45 N | 4 | 50 E | 6:00 p.m. |
Madrid, Spain | 40 | 26 N | 3 | 42 W | 6:00 p.m. |
Manchester, England | 53 | 30 N | 2 | 15 W | 5:00 p.m. |
Manila, Philippines | 14 | 35 N | 120 | 57 E | 1:00 a.m.1 |
Marseilles, France | 43 | 20 N | 5 | 20 E | 6:00 p.m. |
Mazatlán, Mexico | 23 | 12 N | 106 | 25 W | 10:00 a.m. |
Mecca, Saudi Arabia | 21 | 29 N | 39 | 45 E | 8:00 p.m. |
Melbourne, Australia | 37 | 47 S | 144 | 58 E | 3:00 a.m.1 |
Mexico City, Mexico | 19 | 26 N | 99 | 7 W | 11:00 a.m. |
Milan, Italy | 45 | 27 N | 9 | 10 E | 6:00 p.m. |
Montevideo, Uruguay | 34 | 53 S | 56 | 10 W | 2:00 p.m. |
Moscow, Russia | 55 | 45 N | 37 | 36 E | 8:00 p.m. |
Munich, Germany | 48 | 8 N | 11 | 35 E | 6:00 p.m. |
Nagasaki, Japan | 32 | 48 N | 129 | 57 E | 2:00 a.m.1 |
Nagoya, Japan | 35 | 7 N | 136 | 56 E | 2:00 a.m.1 |
Nairobi, Kenya | 1 | 25 S | 36 | 55 E | 8:00 p.m. |
Nanjing (Nanking), China | 32 | 3 N | 118 | 53 E | 1:00 a.m.1 |
Naples, Italy | 40 | 50 N | 14 | 15 E | 6:00 p.m. |
New Delhi, India | 28 | 35 N | 77 | 12 E | 10:30 p.m. |
Newcastle-on-Tyne, England | 54 | 58 N | 1 | 37 W | 5:00 p.m. |
Odessa, Ukraine | 46 | 27 N | 30 | 48 E | 7:00 p.m. |
Osaka, Japan | 34 | 32 N | 135 | 30 E | 2:00 a.m.1 |
Oslo, Norway | 59 | 57 N | 10 | 42 E | 6:00 p.m. |
Panama City, Panama | 8 | 58 N | 79 | 32 W | 12:00 noon |
Paramaribo, Suriname | 5 | 45 N | 55 | 15 W | 2:00 p.m. |
Paris, France | 48 | 48 N | 2 | 20 E | 6:00 p.m. |
Perth, Australia | 31 | 57 S | 115 | 52 E | 1:00 a.m.1 |
Plymouth, England | 50 | 25 N | 4 | 5 W | 5:00 p.m. |
Port Moresby, Papua New Guinea | 9 | 25 S | 147 | 8 E | 3:00 a.m.1 |
Prague, Czech Republic | 50 | 5 N | 14 | 26 E | 6:00 p.m. |
Rangoon, Myanmar | 16 | 50 N | 96 | 0 E | 11:30 p.m. |
Reykjavík, Iceland | 64 | 4 N | 21 | 58 W | 5:00 p.m. |
Rio de Janeiro, Brazil | 22 | 57 S | 43 | 12 W | 2:00 p.m. |
Rome, Italy | 41 | 54 N | 12 | 27 E | 6:00 p.m. |
Salvador, Brazil | 12 | 56 S | 38 | 27 W | 2:00 p.m. |
Santiago, Chile | 33 | 28 S | 70 | 45 W | 1:00 p.m. |
St. Petersburg, Russia | 59 | 56 N | 30 | 18 E | 8:00 p.m. |
S?o Paulo, Brazil | 23 | 31 S | 46 | 31 W | 2:00 p.m. |
Shanghai, China | 31 | 10 N | 121 | 28 E | 1:00 a.m.1 |
Singapore, Singapore | 1 | 14 N | 103 | 55 E | 1:00 a.m.1 |
Sofia, Bulgaria | 42 | 40 N | 23 | 20 E | 7:00 p.m. |
Stockholm, Sweden | 59 | 17 N | 18 | 3 E | 6:00 p.m. |
Sydney, Australia | 34 | 0 S | 151 | 0 E | 3:00 a.m.1 |
Tananarive, Madagascar | 18 | 50 S | 47 | 33 E | 8:00 p.m. |
Teheran, Iran | 35 | 45 N | 51 | 45 E | 8:30 p.m. |
Tokyo, Japan | 35 | 40 N | 139 | 45 E | 2:00 a.m.1 |
Tripoli, Libya | 32 | 57 N | 13 | 12 E | 7:00 p.m. |
Venice, Italy | 45 | 26 N | 12 | 20 E | 6:00 p.m. |
Veracruz, Mexico | 19 | 10 N | 96 | 10 W | 11:00 a.m. |
Vienna, Austria | 48 | 14 N | 16 | 20 E | 6:00 p.m. |
Vladivostok, Russia | 43 | 10 N | 132 | 0 E | 3:00 a.m.1 |
Warsaw, Poland | 52 | 14 N | 21 | 0 E | 6:00 p.m. |
Wellington, New Zealand | 41 | 17 S | 174 | 47 E | 5:00 a.m.1 |
Zürich, Switzerland | 47 | 21 N | 8 | 31 E | 6:00 p.m. |
把表格复制一下贴到文文文档里,文档名为date,输出城市国家和十进制的经纬度
# coding=utf-8 # 东经正数,西经为负数 # 北纬为正数,南纬为负数 lines = open(‘date‘).readlines() for l in lines: if l.find(‘\t‘) >= 0 and not l.startswith(‘#‘): a = l.split(‘\t‘) b = a[2].split(‘ ‘) degree = float(a[1]) minute = float(b[0]) n = 1 if b[1] == ‘N‘ else -1 degree = degree + minute / 60.0 latitude_degree = degree * n b = a[4].split(‘ ‘) degree = float(a[3]) minute = float(b[0]) n = 1 if b[1] == ‘E‘ else -1 degree = degree + minute / 60.0 longitude_degree = degree * n # print a print ‘%s (%s,%s)‘ % (a[0],latitude_degree,longitude_degree)
时间: 2024-10-08 04:08:14