一、格式化输出

  %s  字符串占位

  %d  数字的占位

  %f  浮点数的占位

 

二、编码

ascii: 英文+数字+标点+特殊字符 一共编码了128个. 最早的是7bit => 8bit
计算机网络传输的时候单位是字节 1byte => 8bit
ascii第一位是0

ANSI: 一个标准
GBK: 国标码的扩展码 16bit 2byte 65536个 主要是放中文 一定兼容ascii, 现在大家的windows默认就是GBK

ISO+Unicode=> unicode 万国码 32bit -> 一个面 16bit 65536个文字.
ascii: a 10101010
unicode: a 10101010

utf:可变长度的unicode, 弥补了浪费的空间.
utf-8:
英文: 8bit 1byte
欧洲: 16bit 2byte
中文: 24bit 3byte

python中默认使用的字符串就是unicode
进行网络传输和文件存储必须要转化成utf-8或者gbk

如何把字符串转化成utf-8

encode(编码) => 使用编码格式对文字进行编码
decode(解码) => 把bytes变回字符串

 

三、int

bit_length() :(查询int格式二进制的位数)是int唯一的一个动作.