python 字符串

 很多字符串的方法:

http://www.cnblogs.com/huangcong/archive/2011/08/29/2158268.html


python3的字符串使用unicode编码


字符串的编码:

            ASCII                 UTF-8               unicode           十进制

A          0100 0001           0100 0001                00000000 0100 0001          65

'0'   00110000             00110000                 00000000 0011 0000          48

(字符0,不同于数字0)

中    不可表示          0100111000101101     0100111000101101


ascii   一个字符占用一个字节

unicode 一个字符占用2个字节

utf-8   可变换长度

在内存中,字符用unicode编码,但在传输和保存到硬盘时,用utf-8编码

         ''                    b''

so,python文件保存为utf-8编码

原文地址:https://www.cnblogs.com/mogujiang/p/5620760.html