1 Star 2 Fork 0

羽落风起/python-tool

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
HttpServerTest.py 824 Bytes
一键复制 编辑 原始数据 按行查看 历史
羽落风起 提交于 2020-10-12 10:29 +08:00 . 升级pandas和http工具类
#!/usr/bin/python
#coding:utf-8
'''
http接口测试工具类
'''
import base64
from urllib import request
import json
def fileToBase64(file):
'''
图片转base64
'''
with open(file, 'rb') as fin:
image_data = fin.read()
image_base64 = str(base64.b64encode(image_data))
return image_base64
headers ={
"content-type":"application/json"
}
def requestTest():
img="E:/python-workspace/2020/cv2/158096145222.jpg"
baseImg=fileToBase64(img)
context={"code":"2020_09_03","originalImage":baseImg,"image":baseImg,"imageType":1}
req = request.Request(url = "http://localhost:8081/ocr/led",
headers = headers,
data = json.dumps(context).encode("utf-8"))
reps = request.urlopen(req).read().decode("utf-8")
print(reps)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/wangzonghui/python-tool.git
git@gitee.com:wangzonghui/python-tool.git
wangzonghui
python-tool
python-tool
master

搜索帮助