1.我的目的
2.实现过程
- ① 选择一个第三方平台
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/17c46c32d55849f532de6adc19f1f327.png)
- ② 有这么几个需求:
3.全部代码
import requests
from base64 import b64encode
body = {}
url = "http://imgurlocr.market.alicloudapi.com/urlimages"
appcode = "e6c75f6508ba47d99d902e54ca23abbe"
headers = {
"Authorization": "APPCODE " + appcode,
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
}
post_data = {}
with open("timg.jpg", "rb") as fp:
temp = fp.read()
pic = b64encode(temp)
post_data["image"] = "data:iamge/jpeg;base64,".encode() + pic
response = requests.post(url=url, data=post_data, headers=headers)
print(response.text)