zoukankan      html  css  js  c++  java
  • Python Day 6 基础数据类型(小数据池和bytes)

    Python Day 6

    小数据池

    小数据池:int str 在一定范围内,如果两个数值相同,为了节省内存,共用一个内存地址。

    int: -5 ~ 256

    str :

    1.有非字母元素就不是小数据池。

    2.单个字母* int(21)以下,存在小数据池,手动设置的存在。

    剩下的类型都不存在小数据池。

    id 查询内存地址

    is 内存地址是否相同

    bytes:

    与str方法一样。 

    编码:
    ASCII:数字,字母,特殊字符。
      A:0000 0010
    unicode:万国码。
      A:0000 0000 0000 0101 0000 0101 0000 0101
      中:0000 0000 0000 1101 0000 0000 0000 1101
    升级:
    utf-8:最少用8位表示一个字符。
      A:0000 0010
      欧洲:0000 0010 0000 0010
      中:0000 0000 0000 1101 0000 0000

    gbk:国标,数字,字母,特殊字符,中文。
      A:0000 0010
      中:0000 0000 0000 1101
    不同编码之间不能互相识别。
    在文件的存储或传输,编码是除unicode以外的任意编码。

    python3x
      str:内部编码方式 unicode。
      bytes:内部编码方式 非unicode。

    英文:
      str: 内部编码方式 unicode
      表现形式:name = 'alex'

      bytes: 内部编码方式 非unicode
      表现形式:name = b'alex'

    中文:
      str: 内部编码方式 unicode
      表现形式:name = '中国'

      bytes: 内部编码方式 非unicode
      表现形式:name = b'xe2xe2xe2xe2xe2xe2'

    转换
    str ---> bytes
    b1 = str.encode('utf-8')

    bytes ---> str
    s1 = bytes.decode('utf-8')

  • 相关阅读:
    select选中值传递到后台action中
    select into from 与insert into select from区别
    存储过程
    layer
    下拉框两级联动
    无限纠结——Zedboard上跑ubuntu详解
    静态时序分析SAT
    设计模式-(构型模式)
    内存断点调试的原理
    C语言中使用静态函数的好处
  • 原文地址:https://www.cnblogs.com/eailoo/p/8992233.html
Copyright © 2011-2022 走看看