Python Basic data type 1

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.