码迷,mamicode.com
首页 > 编程语言 > 详细

python 2 encode and decode

时间:2017-10-12 01:09:24      阅读:273      评论:0      收藏:0      [点我收藏+]

标签:ber   memory   nal   编码   poi   cte   version   ted   doc   

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

标签:ber   memory   nal   编码   poi   cte   version   ted   doc   

原文地址:http://www.cnblogs.com/vickey-wu/p/7653554.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!