python3 str.encode bytes.decode
str.encode
把字符串编码成字节序列
bytes.decode
把字节序列解码成字符串
https://docs.python.org/3.5/library/stdtypes.html
str.
encode
(encoding=”utf-8”, errors=”strict”)-
Return an encoded version of the string as a bytes object. Default encoding is
'utf-8'
. errors may be given to set a different error handling scheme. The default for errors is'strict'
, meaning that encoding errors raise aUnicodeError
. Other possible values are'ignore'
,'replace'
,'xmlcharrefreplace'
,'backslashreplace'
and any other name registered viacodecs.register_error()
, see section Error Handlers. For a list of possible encodings, see section Standard Encodings.Changed in version 3.1: Support for keyword arguments added.
bytes.
decode
(encoding=”utf-8”, errors=”strict”)bytearray.
decode
(encoding=”utf-8”, errors=”strict”)-
Return a string decoded from the given bytes. Default encoding is
'utf-8'
. errors may be given to set a different error handling scheme. The default for errors is'strict'
, meaning that encoding errors raise aUnicodeError
. Other possible values are'ignore'
,'replace'
and any other name registered viacodecs.register_error()
, see section Error Handlers. For a list of possible encodings, see section Standard Encodings.Note
Passing the encoding argument to
str
allows decoding any bytes-like object directly, without needing to make a temporary bytes or bytearray object.Changed in version 3.1: Added support for keyword arguments.
最新文章
- jQuery 一些神奇的选择器写法
- SPOJ ONEZERO(搜索)
- Winform设置相关
- jquery plugins —— datatables ajax post更新数据
- android onTouch()与onTouchEvent()的区别
- Mongodb增加权限管理
- ZOJ3551 Bloodsucker(概率dp)
- PCB布线的地线干扰与抑制方法
- iOS中静态库-.a文件生成和使用
- Handler消息传递机制——Handler类简洁
- Equals()和GetHashCode()方法深入了解
- Java transient关键字使用小结
- 面试之路(7)-BAT面试题之计算机的三大原则
- 第二篇--上传git 代码
- Sitecore 8.2 页面架构设计:模板与组件
- jquery mobile Touch事件
- Symfony中Doctrine对应的Mongodb数据类型 data type
- 微信公众号为什么要加粉?流量,广告,KPI,吸粉,增粉
- 使用TryUpdateModel进行数据更新
- 面向对象的JavaScript --- 多态