代码拉取完成,页面将自动刷新
#!/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)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。