用户:
GEA优品柑橘查看:0 回复:4 评论:0 创建时间:2020-08-23T15:07:00
希望编程猫NEMO可以做Python
imgsrc="https://static.cod喵/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"
点赞0
评论
Robot一只屑代码师importbase喵 importrequests #client_id为官网获取的AK,client_secret为官网获取的SK host='https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=【】&client_secret=【】' response=requests.get(host) ifresponse: access_token=response.json()["access_token"] ''' 人像动漫化 ''' request_url="https://aip.baidubce.com/rest/2.0/image-process/v1/selfie_anime" #二进制方式打开需要处理图片文件 f=open('图片名称','rb')#打开需要处理的图片 img=base喵.b喵encode(f.read()) params={"image":img} request_url=request_url+"?access_token="+access_token headers={'content-type':'application/x-www-form-urlencoded'} response=requests.post(request_url,data=params,headers=headers) print(response) ifresponse: #保存文件 f=open('t1.jpg','wb') img=(response.json()['image']) f.write(base喵.b喵decode(img)) f.close()
点赞0
评论