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 a UnicodeError. Other possible values are 'ignore', 'replace', 'xmlcharrefreplace', 'backslashreplace' and any other name registered via codecs.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 a UnicodeError. Other possible values are 'ignore', 'replace' and any other name registered via codecs.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.

最新文章

  1. jQuery 一些神奇的选择器写法
  2. SPOJ ONEZERO(搜索)
  3. Winform设置相关
  4. jquery plugins —— datatables ajax post更新数据
  5. android onTouch()与onTouchEvent()的区别
  6. Mongodb增加权限管理
  7. ZOJ3551 Bloodsucker(概率dp)
  8. PCB布线的地线干扰与抑制方法
  9. iOS中静态库-.a文件生成和使用
  10. Handler消息传递机制——Handler类简洁
  11. Equals()和GetHashCode()方法深入了解
  12. Java transient关键字使用小结
  13. 面试之路(7)-BAT面试题之计算机的三大原则
  14. 第二篇--上传git 代码
  15. Sitecore 8.2 页面架构设计:模板与组件
  16. jquery mobile Touch事件
  17. Symfony中Doctrine对应的Mongodb数据类型 data type
  18. 微信公众号为什么要加粉?流量,广告,KPI,吸粉,增粉
  19. 使用TryUpdateModel进行数据更新
  20. 面向对象的JavaScript --- 多态

热门文章

  1. Day4-T4
  2. CentOS 6.8 32位 安装mysql8
  3. Oracle Exadata 学习笔记之核心特性Part1
  4. jQuery原理系列-Dom Ready
  5. 本地Redis服务配置
  6. ActiveMQ消息队列和SignalR之日志实时监控及警报小实例
  7. 学习spring第五天 mybatis+spring的整合(maven多模块数据查询使用了分页和连接池),以及aop
  8. POJ 3071:Football
  9. 并发 ping
  10. PageHelper使用