python读取图像并上传
import os
import requests
def get_file(path):
files = os.listdir(path)
for file in files:
img_path = os.path.join(path, file)
yield img_path
if __name__ == '__main__':
path = r'F:\image\8\dianzi\张欣欣标注0~999张\0~499'
for img_path in get_file(path):
f = open(img_path, 'rb')
file = {'file': f.read()}
f.close()
res = requests.post(url='http://192.168.10.218:58081/identify', files=file)
print(res.json()['发票类型'])
f.close()
# return_info = {"result": [str(res.json())]}