请教如何解决TypeError:'str' does not support the buffer interface
最近在学python(我用的是python3)的web编程,然后照着写了个验证登录程序,其中有段代码(uid,pw)=base64.b64decode(request.headers['Authorization').split(' ')[-1]).split(';')
结果在利用requests请求的时候报错:TypeError:'str' does not support the buffer interface,问题定位的也是上面那一句代码。在网上查了下说是因为编码的问题,python3和python2的string类型不一样,不过仍然不会解决。
首先确认一下要发送的参数,是不是发送base64编码字符。
试试改成:uid,pw=base64.b64decode(request.headers['Authorization'].split(' ')[-1].encode()).split(';'),将字符串类型改为字节型。再用base64解码。
具体参考:
https://www.cnblogs.com/Simon-xm/p/4073129.html
如有帮助,请采纳。点击我回答右上角【采纳】按钮。