1, binary: The data stored on the hard disk are saved in binary form. A byte occupies 8 bits, consisting of 0 and 1, every 2 into 1. For example, a Chinese character "King", in the UTF-8 encoding format, the hard disk accounted for 3 bytes 24 bits, if the GBK encoding format, then accounted for 2 bytes, accounted for 16 bits.
Save data on hard disk: 01010010
READ: 01010100-"The corresponding encoding of Chinese characters-" xx
See two kinds of: ① conversion completed string, such as: Kanji, characters, English letters, etc.
The ② is displayed in hexadecimal.
F1 = open (' Log ', ' R ', encoding= ' UTF-8 ') #因为文件中包含汉字, identity read encoding format data = F1.read () f1.close () print (data) #打印出: Kanji JDJKDFJD at a time see accessories enlarged
F1 = open (' Log ', ' RB ') #rb means to display data = F1.read () f1.close () print (data) #b ' jdjkdfjd\xe5\x87\xa0\xe7\x82\ in 16 binary Xb9\xe8\xa7\x81\xe9\x99\x84\xe4\xbb\xb6 \xe6\x94\xbe\xe5\xa4\xa7 ' #以b开头即表示是以16进制显示, where \xe5\ is a byte, 7 characters exactly 21 bytes
Binary: every 2 in 1
Octal: every 8 in 1
Decimal: Every 10 in 1
Hex: Every 16 in 1 1,2,3,4,5,6,7,8,9,a,b,c,d,e,f
2.
Python Basic data type 1