python 3.3 base64
来源:互联网 发布:七牛云加速域名 编辑:程序博客网 时间:2024/05/29 10:27
>>> s='我'
>>> base64.b64encode(s)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python33\lib\base64.py", line 58, in b64encode
raise TypeError("expected bytes, not %s" % s.__class__.__name__)
TypeError: expected bytes, not str
出现上面的错误,就用下面这行。
>>> base64.b64encode(s.encode(encoding='utf-8'))
b'5oiR'
>>> base64.b64encode(s.encode(encoding='utf-8')).decode('utf-8')
'5oiR'
对于\u开关的字符也可以处理了。
>>> str1 = '\u4f60\u597d'
>>> str1.encode(encoding='utf-8').decode()
'你好'
>>>
0 0
- python 3.3 base64
- python base64
- python模块之base64
- python的模块base64
- python模块之base64
- python模块之base64
- python base64加密
- 【python】读写base64文件
- python 实现base64编码
- python实例27[base64]
- python Base64编码
- python模块之base64
- Python base64模块详解
- python base64 加密 解密
- Python base64模块
- Python的base64
- Python base64编码
- Python PIL & base64
- head first设计模式(一)——策略模式
- struts1+jdbc增删改查
- Django1.6+jQuery Ajax + JSON 实现页面局部实时刷新
- [Android]Android.mk 详解
- 2016年这些 Android 技术必火(转载)
- python 3.3 base64
- PHP-学习笔记 延迟静态绑定
- 如何构建用户画像
- 欢迎使用CSDN-markdown编辑器
- tcp连接超时处理
- Spark编译报错问题日志记录
- iPhone开发 – 小技巧二则 (UIColor 16进制颜色 | UIview设置frame)
- C++32 调用 C# 64编写的dll
- {最代码}如何在eclipse jee中检出项目并转换为Maven project,最后转换为Dynamic web project