全球主要城市经纬度及转化为十进制的小脚本

工作需要,找全球主要城市的经纬度,发现百度出来的结果不是截图就是无法下载,总之不能愉快的拿来用,祭出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

全球主要城市经纬度及转化为十进制的小脚本的相关文章

世界主要城市经纬度

城市英文名 城市中文名 所属国家 纬度 经度 Abidjan 阿比让 科特迪瓦 北纬:5°19' 东经:4°01' Abu Dhabi 阿布扎比 阿联酋 北纬:24°27' 东经:54°23' Abuja 阿布贾 尼日利亚 北纬:9°12' 东经:7°11' Acapulco 阿卡普尔科 墨西哥 北纬:16°51' 西经:99°56' Accra 阿克拉 加纳 北纬:5°33' 东经:0°15' Adak 艾达克岛 美国 北纬:51°52' 东经:176°39' Adamstown 亚当斯敦 英

labVIEW将字符串解释成十六进制并转化为十进制

作用:将ASCII当做成十六进制来表示,并计算这个十六进制数对应的十进制大小 例如:008A本身对应的ASCII码用十六进制表示为为30 30 38 41,但有些协议中将008A当成0x008A来表示,所以需要将008A阐释为0x008A,则对应的十进制大小为139

城市经纬度(阿里云)

#encoding:UTF-8 #Python 3.4.3 import urllib import requests def get_info(): city=input('请输入要查询的城市名称:') url='http://gc.ditu.aliyun.com/geocoding?a='+urllib.parse.quote(city) weather_data = urllib.request.urlopen(url).read() weather_data =eval(weather_

全国城市经纬度

/* Navicat MySQL Data Transfer Source Server : 192.168.1.194 Source Server Version : 50626 Source Host : 192.168.1.194:3306 Source Database : user Target Server Type : MYSQL Target Server Version : 50626 File Encoding : 65001 Date: 2015-09-07 15:38:5

二进制转化成十进制(转)

二进制数的加法和乘法运算如下: 0+0=0 0+1=1+0=1 1+1=10 0×0=0 0×1=1×0=0 1×1=1 二进制数.转换为十进制数的规律是:把二进制数按位权形式展开多项式和的形式,求其最后的和,就是其对应的十进制数——简称“按权求和”. 例如:把(1001.01)2转换为十进制数. 解:(1001.01)2 =1×(2的3次方)+0×(2的2次方)+0×(2的1次方)+1×(2的0次方)+0×(2的-1次方)+1×(2的-2次方) =8+0+0+1+0.5+0.25 =9.75

四座中国城市入选全球创意城市网络 他们靠的啥?lt

"财富品质研究院预测,未来奢侈品定制产业将迎来规模化发展机会,能体现个人色彩的奢侈品牌将受到更多追捧."原来,比伯与格里芬有过一段恩怨,比伯曾在好莱坞一家咖啡店被某咖啡师拒绝服务,原因是他衣衫不整,让人感觉不受尊重.5000大卡长协价格530元吨,月度长协和现货价格均统一为575元吨,现货价格相比前期下降40元吨今年以来,一系列突破性的新举措,打造出农村民兵工作的"升级版"."19时30分,本该刘涛下班的时间,但他必须要在下班后将今天全部病人的病史记录填写

栈应用之将二进制转化为十进制,八进制,十六进制

1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<math.h> 4 5 #define INIT_STACK_SZIE 20 6 #define STACK_INCREMENT 10 7 #define OK 1 8 #define ERROR 0 9 10 typedef char Elemtype; 11 typedef int Status; 12 13 typedef struct SuqStack{ 14

十六进制转化为十进制

package lsh.element.numbersystem; import java.util.Scanner; /** * * @desc 有意思的地方:两种思想得到的结果都是正确的,但是超出int类型最大之后,错误值却不同 * * @author * LSH * 2018年9月23日 */ public class HexToDecimalConversion { public static void main(String[] args) { System.out.println((

十六进制字符串转化为十进制整数

代码: int zh(char s[]) { int i,m,temp=0,n; m=strlen(s);//十六进制是按字符串传进来的,所以要获得字符串长度 for(i=0;i<m;i++) { if(s[i]>='A'&&s[i]<='F')//十六进制还要判断字符是不是在A-F或者a-f之间 { n=s[i]-'A'+10; } else if(s[i]>='a'&&s[i]<='f') { n=s[i]-'a'+10; } else {