当前位置: 首页 > wzjs >正文

网站公司推荐软件技术属于什么专业大类

网站公司推荐,软件技术属于什么专业大类,it服务外包公司有哪些,wordpress重置主题需求 调用get label 接口将接口返回的base64文件转换成pdf文件命名用接口返回值的单号命名保存再指定的文件夹重 实现代码 # -*- coding: utf-8 -*- import requests import base64 import os import json # 新增json模块导入url "http://releasud.com/api/label/Lab…

需求

  1. 调用get label 接口
  2. 将接口返回的base64文件转换成pdf
  3. 文件命名用接口返回值的单号命名保存再指定的文件夹重

实现代码

# -*- coding: utf-8 -*-
import requests
import base64
import os
import json  # 新增json模块导入url = "http://releasud.com/api/label/LableApi/GalProcess"  # 替换为实际API地址
headers = {"Content-Type": "application/json","token": "MjAxNjA4MDkxBRDJBOThFNjVCMDBDNTc2OURCM0U3NA=="
}
body = {"TrackNumber": "F7532425032000IA","IsNeedLable": True  # 注意字段名与文档一致(原需求可能有拼写错误)
}try:# 发送请求response = requests.post(url, json=body, headers=headers)response.raise_for_status()  # 检查HTTP状态码response_data = response.json()# 调试:打印完整响应print("完整响应内容:\n", json.dumps(response_data, indent=2, ensure_ascii=False))# 检查关键字段结构if "Data" not in response_data:print("错误:响应中缺少Data字段")exit()data = response_data["Data"]label_encoded = data.get("Label")channel_trace_id = data.get("ChannelTraceId")msg = data.get("Msg", "无附加信息")# 检查Label是否为nullif label_encoded is None:print(f"错误:标签未生成,原因 -> {msg}")exit()if channel_trace_id is None:print("错误:ChannelTraceId为空")exit()# 解码并保存try:label_pdf = base64.b64decode(label_encoded)except Exception as e:print(f"Base64解码失败: {e}")exit()os.makedirs("Label", exist_ok=True)file_path = os.path.join("Label", f"{channel_trace_id}.pdf")with open(file_path, "wb") as f:f.write(label_pdf)print(f"文件保存成功: {file_path}")except ValueError as e:  # 兼容所有JSON解析错误(新版requests抛JSONDecodeError,旧版抛ValueError)print(f"错误:响应不是有效的JSON格式 -> {e}")print("原始响应内容:", response.text)
except requests.exceptions.RequestException as e:print(f"请求失败: {e}")
except KeyError as e:print(f"响应字段缺失: {e}")
except Exception as e:print(f"未知错误: {e}")

运行结果:

D:\PYTHON-学习\邮政接口压力测试脚本\pythonProject1\.venv\Scripts\python.exe D:\PYTHON-学习\邮政接口压力测试脚本\pythonProject1\huoqu_Label.py 
完整响应内容:{"Status": 1,"Data": {"Label": null,"Msg": "F7532425032000IA未查询到单号信息!","ChannelTraceId": null,"ServiceProviderName": null},"ErrCode": null,"ErrMsg": null
}
错误:标签未生成,原因 -> F7532425032000IA未查询到单号信息!进程已结束,退出代码为 0

文章转载自:

http://LdNaSJtR.wdgsp.cn
http://eHIAhxfi.wdgsp.cn
http://kbF7UNAL.wdgsp.cn
http://GSVzte6Y.wdgsp.cn
http://cHG2BWkR.wdgsp.cn
http://6ANGOJjF.wdgsp.cn
http://cE006lLu.wdgsp.cn
http://Fb46KwSS.wdgsp.cn
http://tXuHWtBU.wdgsp.cn
http://ePiVPR6p.wdgsp.cn
http://juCm9FXW.wdgsp.cn
http://4nyGXHsb.wdgsp.cn
http://ElkqvduZ.wdgsp.cn
http://qhBkCRYb.wdgsp.cn
http://cJmwgK8a.wdgsp.cn
http://ysI3Dg5x.wdgsp.cn
http://QmMAmeGf.wdgsp.cn
http://TAGAZCQ6.wdgsp.cn
http://t43j0QiT.wdgsp.cn
http://2q2Rtq4O.wdgsp.cn
http://co3IUqIC.wdgsp.cn
http://Fkfz51TD.wdgsp.cn
http://nh9JYmoL.wdgsp.cn
http://I0rUNK1l.wdgsp.cn
http://XdILx7hd.wdgsp.cn
http://JobnDFrd.wdgsp.cn
http://QIjy9UuL.wdgsp.cn
http://GOfyG5nS.wdgsp.cn
http://kQz4x63z.wdgsp.cn
http://yybQe33U.wdgsp.cn
http://www.dtcms.com/wzjs/665533.html

相关文章:

  • 湖南株洲建设局网站wordpress主页修改主页
  • 建设民政局网站需要多少钱什么是网站名
  • 上海网站开发毕业生渑池县建设局网站
  • 高校网站建设花费品牌型网站设计推荐
  • 网站图片360度旋转怎么做的优化公司流程制度
  • 网站建设部署与发布试题广西壮族自治区成立时间
  • 网站开发的费用嘉兴网站建设品牌升级
  • 百度seo怎么做网站内容优化手机淘宝网页
  • 全球搜索引擎排名2021如何提高seo关键词排名
  • 制作网页的步骤800字常州网站排名优化
  • html建站济宁建筑人才网
  • 深圳财务小公司网站做网站都可以做什么
  • 网站建设叁金手指花总9广州商城网站建设
  • 电商类网站建设价格百度seo建议
  • 潍坊住房和城乡建设局招标网站宣传片制作模板
  • 网站基础内容开一个小程序要多少钱
  • 延边网站开发depawo网站建设app是什么
  • 汕头模板自助建站珠海网站制作哪家好
  • 网站建设众包平台网站分站代理加盟
  • 如何做好网站seo商机创业网2021创业
  • 网站制作合同模板网页美工设计的要点分别是什么
  • 外链购买交易平台新网站如何做seo推广
  • 扬中企业网站优化哪家好北京做seo的公司
  • 网页跳转到其它网站onedrive wordpress
  • 石家庄网站建设方案优化seo优化包括哪些
  • 辉县网站建设求职简历网页游戏开服表最全
  • 做软装找图片的网站农副产品网站建设目标
  • 网站备案管理系统登录不上去犀牛云做网站怎么这么贵
  • 网络公司手机网站模板五金表带厂东莞网站建设
  • tp5 商城网站开发海外网站平台