Coding day08

Character (the information stored stuff) encoding ()

Keyboard is the current transmission - a "host (master) is received by the current (as 01010101010) -" is displayed to accept the computer (as 01010101010-- "keyboard)
encoding: 01010101010 -" Keyboard

Process text editor to store information

Text Editor - "write text -" to store information

Display (memory) - "(conversion) hard disk

Chinese - "00101101001010

english-》111110000

Toilet paper - "00,000,011,111

Early American talent with computer

0->a

1->b

ascii coding - "The Americans

# ascii编码的转换关系的方法
print(chr(65))
print(ord('a'))

Japan has its own code. South Korea, China has also been - "gb2312

This time there have been unicode encoded (corresponding to a relationship)
unicode encoded nations may know

No matter what format your hard drive lying encoded files, unicode can be identified.

Assumption Japanese file from the hard disk to read Japanese encoding, then unicode recognition, unicode help you convert gb2312,

To solve the garbage problem with unicode storage, unicode by taking, after the code is unicode

But unicode save time space, so there utf8 (unicode and only one correspondence) - "solve the problem unicode memory footprint

Now the computers are so - "** unicode memory load, store by store utf8 (hard), people around the world to write code / write documents are utf8

Memory Why not utf8? uf8 and gb2312 / encoding Japan relations are not converted, so the memory to be used for unicode

Future Sooner or later, the memory use utf8

Gbk gb2312 and the difference

gb1312 -> common words

gbk -> All words

This notebook windows system default encoding is gbk, all except utf8

What to write code, you read what encoding

Written utf8, deposit with utf8, read with gbk-- "garbled

Written utf8, deposit with gbk-- "garbled. Reading with - "

Encoding and decoding

unicode encoding - "(code) from memory to the hard disk UTF8

utf8 - "(decoding) from the hard disk into memory Unicode

Memory is now only unicode encoding

python interpreter (text editor) python code interpretation process

python2 default coding head is ascii, python3 default utf8-- "1, python interpreter corresponding to a text editor, the code is read into interpreter python - -" character code "

中文 # gbk编码的中文加

2, identification code - "print meaningful -" syntax problem

# coding:gbk  # 告诉python解释器用gbk去完成第一步,读入字符
中文

3, produce a result - "go Terminal -" character encoding

Terminal has a feature: What is your computer coding, coding what would follow, windows terminal is gbk

In addition to coding error codes, first add # - * coding: utf8 * -

Guess you like

Origin www.cnblogs.com/shin09/p/11537389.html
Recommended