欢迎光临
我们一直在努力

python之base64编码出现b的问题(转)

mystr = '人生苦短,py是岸'
mystr = base64.b64encode(mystr.encode('utf-8'))
print(mystr)
输出结果:b'5Lq655Sf6Ium55+t77yMcHnmmK/lsrg='

现在我们要获取纯字符串,也就是不要b,那么如下这样写,也就是b64encode后用decode(‘ascii’)解码一下

mystr = '人生苦短,py是岸'
mystr = base64.b64encode(mystr.encode('utf-8')).decode('ascii')
print(mystr)
输出结果:5Lq655Sf6Ium55+t77yMcHnmmK/lsrg=

 

赞(0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址