您的位置:首页 > 移动开发 > Objective-C

python中Base64编码和解码:TypeError: a bytes-like object is required, not 'str'

2017-07-31 08:51 996 查看
在目前最新版本下出现问题
F:\p>python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

#-*- coding: utf-8
import base64

str='cnblogs'
str64=base64.b64encode(str)
print(str64) #Y25ibG9ncw==
print(base64.b64decode(str64)) #cnblogs

正确修改str=b'cnblogs'                           
 就能解决问题。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐