• Python调接口动态获取数据源,并处理CSV数据源驱动


    一、接口获取数据源,并落库
    二、拆分、合并、处理表数据
    三、处理生成新数据,生成ECSV数据源
    四、文件上传至服务器


    上传文件接口
    def atpUpload():
            files = {"file": (
            "atpUploadDemo.csv", open("./atpUploadDemo.csv",encoding='utf-8').read(), "application/vnd.ms-excel"),
            "Content-Type": "application/vnd.ms-excel",
            "filename": "atpUploadDemo.csv",
            }
    
    
     url='http://XX/api/v1/case/exec/dataDriverUpload'        headers={
                     "Accept":"application/json, text/plain, */*",
                     "Accept-Encoding":"gzip, deflate",
                     "Accept-Language":"zh-CN,zh;q=0.9",
                     "Connection":"keep-alive",
                     "Content-Length":"1846",
                     "Host":"XX",
                     "Origin":"http://XX",
                     "Referer":"http://XX/",
                     "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36",
                     }   
    
            #datas = dict(env="PRD",type= "")
            datas= {"env": "PRD", "type":2}
            result=requests.post(url=url,headers=headers,files=files,data=datas) 
    
    if __name__ == '__main__':
        atpUpload()
    
    
    

    接口获取经纬度

    def getCityCodeGPS_Dest(cityCode):
        r = requests.get('https://geo.datav.aliyun.com/areas/bound/geojson?code='+cityCode+'_full')
        data = json.loads(r.text)
        try:
            gpsLon = data['features'][1]['properties']['center'][0]
            gpsLat = data['features'][1]['properties']['center'][1]
        except:
            gpsLon = data['features'][1]['geometry']['coordinates'][0][0][0]
            gpsLat = data['features'][1]['geometry']['coordinates'][0][1][1]
        return gpsLon, gpsLat















    from common.Log import MyLog as Log
    写法不完善
    修改为 import common.Log.MyLog as Log 即可

    
    
  • 相关阅读:
    ITMS-90809
    iOS ipa 优化减小安装大小
    Xcode 常用路径
    如何查看 Assets.car 内资源
    UILabel 实现圆角
    iOS 改变 UITextField 的 Placeholder 的字体与颜色
    ATS (App Transport Security)
    iOS semaphore 使用
    macOS 自定义 NSButton
    iOS开发——设计模式那点事
  • 原文地址:https://www.cnblogs.com/Shanghai-vame/p/7235373.html
Copyright © 2020-2023  润新知