报not a valid non-string错
cheeryoung79 发布于2020-11-05 浏览:1325 回复:2
0
收藏

为啥报not a valid non-string sequence or mapping object错?

脚本如下

image_file ='facs_images/happy0.jpg'


params = "{\"image\":\""+base64.b64encode(open(image_file,'rb').read()).decode()+"\"}"
#print(params)

access_token = '。。。。。。'
request_url = request_url + "?access_token=" + access_token
request = urllib.request.Request(url=request_url, data=bytes(parse.urlencode(params),'utf8'))
request.add_header('Content-Type', 'application/json')
response = urllib.request.urlopen(request)

收藏
点赞
0
个赞
共2条回复 最后由cheeryoung79回复于2020-11-06
#3cheeryoung79回复于2020-11-06

quote_plus(bytes(parse.urlencode(params),'utf8')))

quote_plus(parse.urlencode(params),'utf8'))

quote_plus(parse.urlencode(params)))

都报报not a valid non-string sequence or mapping object错

0
#2七年期限回复于2020-11-05

urlencode更新后改为quote_plus试试?

0
TOP
切换版块