zoukankan      html  css  js  c++  java
  • 编码

    ascii

    A 00000010 8位 一个字节

    uncode

    A 000000000 00000001 00000010 00000100 32位

     中000000000 00000001 00000010 00000110 32位

    utf-8

    A 0010 0000 8位 一个字节

    中 000000000 00000010 00000110 24位 三个字节

    gbk

    A 00000110 8 位 一个字节

    中 00000010 00000110 16位 两个字节

    1.各个编码之间的二进制, 是不能相互认识的,会产生乱码

    2.文件的储存,传输,不能是uncode,只能是(ascii gbk gb2312 utf- 8 utf-16)

    python3 的str编码就是uncode

         bytes类型使用gbk和utf-8等

    对于英文

         str表现形式

          str="feaf"

         编码方式

           uncode 01010101

        bytes 表现形式

          bytes=b"fafe"

        编码方式 00101010 utf-8 gbk

    对于中文

        str表现形式

          str="中文"

         编码方式

           uncode 01010101

        bytes 表现形式

          bytes=b"/fef"#看不懂

        编码方式 00101010 utf-8 gbk

        

        str="fhahjf"

        s22=str.encode("utf-8")#encode把str转化成bytes

        print(s22)

        s2=str.encode("gbk")#encode把str转化成gbk(bytes)

        print(s2)

  • 相关阅读:
    <转> 百度空间 最大子图形问题详解
    Hdu 1124 Factorial
    Uva 457 Linear Cellular Automata
    求01矩阵中的最大的正方形面积
    【HYSBZ】1036 树的统计Count
    【SPOJ】375 Query on a tree
    【POJ】3580 SuperMemo
    【CodeForces】191C Fools and Roads
    【FOJ】2082 过路费
    【HDU】3726 Graph and Queries
  • 原文地址:https://www.cnblogs.com/648071634com/p/11647126.html
Copyright © 2011-2022 走看看