zoukankan      html  css  js  c++  java
  • 【python】使用python按照一定格式批量输出,地图热力图经纬度格式生成器

    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},
  • 相关阅读:
    Socket 传送文件
    spring
    Hibernate学习笔记
    servlet之过滤器(转载)
    java 网络编程
    java 文件操作
    java 图形界面 邮件系统
    简易俄罗斯方块
    二叉树习题之重建二叉树
    将博客搬至CSDN
  • 原文地址:https://www.cnblogs.com/helenlee01/p/12617452.html
Copyright © 2011-2022 走看看