zoukankan      html  css  js  c++  java
  • python 2 encode and decode

    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的字符将被视为错误。

  • 相关阅读:
    获取移动端屏幕的宽度的方法
    document.body 与 document.documentElement区别介绍
    鼠标放上去会变化
    获取当前日期的函数
    侧边栏和右边高度的问题
    【Ajax】接收后台数据在html页面显示
    JS获取屏幕的大小
    python——字符串的方法及注释&字符串格式化符号含义及转义字符含义
    python——元组
    python——列表操作符
  • 原文地址:https://www.cnblogs.com/vickey-wu/p/7653554.html
Copyright © 2011-2022 走看看