【python】使用python按照一定格式批量输出,地图热力图经纬度格式生成器

荒凉一梦 提交于 2020-03-04 15:54:44

python使用列表按照一定格式批量输出,配合地图热力图程序“食用”更佳哦~

import re
import random
posi = [
'113.936539169252,22.5385001957843',
'126.541615090316,45.8088258279521',
'126.675638499523,45.7658661637579',
'125.296653763226,43.8524275671504',
'125.295401255854,43.8406414749619',
'125.330602075906,43.8219535010431',
'123.465461035375,41.8022741388046',
'123.471096644822,41.6838300691906',
]
count = [
'549',
'36',
'243',
'713',
'697',
'97',
'883',
'59'
]
listlng = []
listlat = []
for i in posi:
    lng = i.split(',')[0]
    lat = i.split(',')[-1]
    listlng.append(lng)
    listlat.append(lat)
#print(listlng)
for j in range(0,len(posi)):
#    print(listlng[j],listlat[j],count[j])
    #count = random.randrange(0, 101)
    print('{"count": %s, "lat": %s, "lng":%s},' %(count[j],listlat[j],listlng[j]))

运行结果:

{"count": 549, "lat": 22.5385001957843, "lng":113.936539169252},
{"count": 36, "lat": 45.8088258279521, "lng":126.541615090316},
{"count": 243, "lat": 45.7658661637579, "lng":126.675638499523},
{"count": 713, "lat": 43.8524275671504, "lng":125.296653763226},
{"count": 697, "lat": 43.8406414749619, "lng":125.295401255854},
{"count": 97, "lat": 43.8219535010431, "lng":125.330602075906},
{"count": 883, "lat": 41.8022741388046, "lng":123.465461035375},
{"count": 59, "lat": 41.6838300691906, "lng":123.471096644822},

 

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!