https://docs.python.org/2/howto/unicode.html

a Unicode string is a sequence of code points, which are numbers from 0 to 0x10ffff. This sequence needs to be represented as a set of bytes (meaning, values from 0–255) in memory. The rules for translating a Unicode string into a sequence of bytes are called an encoding.

一个Unicode字符串是一个序列的编码点,是从0至0x10ffff的数值。这个序列需要在内存中表示为一组字节(意味着从0到255的值)。将一个Unicode字符串翻译成一个字节序列被称为编码。

UTF-8 is probably the most commonly supported encoding. UTF stands for “Unicode Transformation Format”, and the ‘8’ means that 8-bit numbers are used in the encoding

utf-8 是最普遍支持的编码。utf 表示“统一编码转换格式”, 8 表示8位编码统一编码转换格式

Python’s 8-bit strings have a .decode([encoding], [errors]) method that interprets the string using the given encoding

Python的8位字符串有一个解码([编码],[错误])方法,它使用给定的编码来解释字符串

The unicode()constructor has the signature unicode(string[, encoding, errors]). All of its arguments should be 8-bit strings. The first argument is converted to Unicode using the specified encoding; if you leave off the encoding argument, the ASCII encoding is used for the conversion, so characters greater than 127 will be treated as errors

unicode()构造体有个标志函数unicode(string[, encoding, errors]).所有参数都应是8比特字符串。使用指定的编码将第一个参数转换为Unicode;如果去掉编码参数,则使用ASCII编码进行转换,因此大于127的字符将被视为错误。

python 2 encode and decode的更多相关文章

  1. Python 关于 encode与decode 中文乱码问题

    字符串在Python内部的表示是unicode编码,因此,在做编码转换时,通常需要以unicode作为中间编码,即先将其他编码的字符串解码(decode)成unicode,再从unicode编码(en ...

  2. python 的 encode 、decode、字节串、字符串

    一.摆个图 DJ  DJ  DJ   Decode. J 解码 首先得知道字符串有哪些编码格式,至于为什么会有这么多的编码格式,以后再了解更新. 1.ASCII 占1个字节,只支持英文 2.GB231 ...

  3. python编码encode和decode

    计算机里面,编码方法有很多种,英文的一般用ascii,而中文有unicode,utf-8,gbk,utf-16等等. unicode是 utf-8,gbk,utf-16这些的父编码,这些子编码都能转换 ...

  4. python之encode和decode编码

    u = '中文' str3 = u.encode('utf-8') # 以utf-8编码对u进行编码,获得bytes类型对象 print(str3) u2 = str3.decode('utf-8') ...

  5. 【python】python新手必碰到的问题---encode与decode,中文乱码[转]

    转自:http://blog.csdn.net/a921800467b/article/details/8579510 为什么会报错“UnicodeEncodeError:'ascii' codec ...

  6. 【python】浅谈encode和decode

    对于encode和decode,笔者也是根据自己的理解,有不对的地方还请多多指点. 编码的理解: 1.编码:utf-8,utf-16,gbk,gb2312,gb18030等,编码为了便于理解,可以把它 ...

  7. python encode和decode函数说明【转载】

    python encode和decode函数说明 字符串编码常用类型:utf-8,gb2312,cp936,gbk等. python中,我们使用decode()和encode()来进行解码和编码 在p ...

  8. 字符编码和python使用encode,decode转换utf-8, gbk, gb2312

    ASCII码 标准ASCII码使用7位二进制数表示大写或小写字母,数字0到9标点符号以及在美式英语中使用的特殊控制字符. 在标准ASCII码中,最高位(b7)用作奇偶校验位,所谓奇偶校验,是指在代码传 ...

  9. python的str,unicode对象的encode和decode方法

    python的str,unicode对象的encode和decode方法 python中的str对象其实就是"8-bit string" ,字节字符串,本质上类似java中的byt ...

随机推荐

  1. centos 6.2 pptp 客户端 安装(转载)

    转自:http://www.lnmpblog.com/archives/611 centos 6.2 64.bit的桌面版本.配置vpn客户端. 步骤: 1.yum -y install pptp 2 ...

  2. 让CentOS启动后直接进入命令行模式(转载)

    转自:http://361324767.blog.163.com/blog/static/114902525201285101410206/ CentOS中如何进入图形界面和文字界面,Linux真正的 ...

  3. Excel学习 -- 函数基础

    Excel函数基础 1. 单元格是函数的作用对象:    2. 函数由等号.函数表达式.操作符.参数.返回值五部分组成:    3. 商业智能报表中使用的常用函数分类:数学函数.文本函数.逻辑函数.查 ...

  4. bzoj 3307: 雨天的尾巴【树剖lca+树上差分+线段树合并】

    这居然是我第一次写线段树合并--所以我居然在合并的时候加点结果WAWAWAMLEMLEMLE--!ro的时候居然直接指到la就行-- 树上差分,每个点建一棵动态开点线段树,然后统计答案的时候合并即可 ...

  5. 《开源自主OdooERP部署架构指南》试读:第二章数据库服务构建

    文/开源智造联合创始人老杨 本文来自<开源自主OdooERP部署架构指南>的试读章节.书籍尚未出版,请勿转载.欢迎您反馈阅读意见. 使用apt.postgresql.org 您可以选择使用 ...

  6. magento CURD操作

    查询: $model = Mage::getModel('mynews/mynews'); $collection = $model->getCollection(); $collection- ...

  7. Xcode7 使用AFNetWorking 报错 添加Security.framework

    Undefined symbols for architecture x86_64: "_SecCertificateCopyData", referenced from: _AF ...

  8. AJPFX关于abstract的总结

    抽象类: abstract抽象:不具体,看不明白.抽象类表象体现.在不断抽取过程中,将共性内容中的方法声明抽取,但是方法不一样,没有抽取,这时抽取到的方法,并不具体,需要被指定关键字abstract所 ...

  9. Saleae Logic添加NEC IR协议

    一.下载需要用到的代码 Git clone https://github.com/LiveOverflow/NECAnalyzer.git git clone --recursive https:// ...

  10. DeltaFish 选题报告总结

    选题结果:校园物资流动系统 报告地点:3A101 会议时间:16:00 ~ 18:00 与会人员:软工小组全体成员 请假人员:无  缺席人员:无 报告人:陈志锴 一.报告内容总结 1.产品功能 针对校 ...