One 、 What is coding

so to speak , The computer is a smart and stupid guy . Say it's smart , Because he can do a lot of things , It's powerful, needless to say , We should all know and feel . But why is he a fool , Because every word we write on the computer , Every voice saved 、 Songs and little movies , It doesn't know , Because these things are not what it can read . And if we let it do something , Then we have to use the language it can read to make them serve us . So you need to define a set of things that it can read “ Language “ standard , And this “ Language ”, It's called coding .

Two 、 The types and development of coding

We all know , The reason why computers can read data , Because there are many diodes in it , Each diode is like a small light bulb , There are only two states of a small light bulb , Yao Meiliang , Or it doesn't light up . So we use 0 It doesn't light up , use 1 If it's bright , Each little light bulb will have two values ,0 and 1. So if there are two little bulbs , So it has 4 Maybe ,00,01,10,11. If we use 00 Express A、01 Express B,10 Express C,11 Express D, So two little bulbs can say 4 Because of the letters ! Empathy ,3 A small light bulb means 8 Letters …… By analogy , We can use a lot of little light bulbs to show N There are letters .

therefore , The oldest type of coding ASCASCII The code appears !

Everybody knows , The computer was invented by the Americans , They didn't think that computers would develop so fast at first , It's so popular , So only the English letters and characters they use are defined , And these letters or characters , use 7 Bit 0、1 The combination is enough , But they foresee that more characters may be added in the future , So one more bit is reserved so that more characters can be represented later ( That's why ASCII The first of all is 0), So I decided to use... For each character 0 Or composed of 8 To said , In this way, we can express 2**8 = 256 It's possible .

The problem is , Although they cleverly foresee that more characters may be added in the future , But they're still a little conservative , As computers become more powerful , It's more and more widely used , More and more countries are importing computers , only 256 Of characters ASCII It's far from enough .

therefore , There's a more powerful code coming up ,Unicode code , It's also called the universal code .Unicode The code specifies that a character should use at least 2 Bytes (1 Bytes are 8 position ) To express , So at least 2**16=65536 It's possible . But it turns out ,65536 It may not be enough to represent all the characters in the world , Everybody knows , Just Chinese has tens of thousands of characters , And then there was the addition of complements , use 4 Bytes (32 position ) To express , So there is 2*32 It's possible , That's enough to represent all the characters in the world .

Here comes the question , Clearly because letters and symbols only use 8 A bit means , result Unicode Code with 32 To said , The actual use of the total English alphabet to account for a large proportion of , This leads to a serious waste of resources , Wasted a lot of storage space , So then there was another kind of coding ,UTF-8

UTF-8 The code is right Unicode Optimization of coding , It stipulates that , English letters are represented in one byte , Some European symbols use 2 In bytes , Some characters in Asian countries use 3 In bytes , That makes a lot of sense , What should be long , It should be short .

3、 ... and 、Python The default encoding for

▷python2 The default character encoding in the version is ASCII code , If you want to display Chinese, you must write in the first line of the code “  # -*- encoding:utf-8 -*-    ” To specify the encoding

▷python3 The default character encoding is UTF-8, You can display Chinese

Four 、 Conversion relation

▷1 position = 1bit

▷8bits = 1bytes = 1 byte

▷1024bytes = 1KB

▷1024KB = 1MB

▷1024MB = 1GB

▷1024GB = 1TB

5、 ... and 、 appendix :ASC Code book

ASCII(American Standard Code for Information Interchange, American standard information exchange code ) It's a computer coding system based on the Latin alphabet , Mainly used to show modern English and other western European languages , It can only be used at most 8 To said ( A byte ), namely :2**8 = 256, therefore ,ASCII Code can only represent at most 256 Symbols .

Bin( Binary system )
Oct( octal )
Dec( Decimal system )
Hex( Hexadecimal )
abbreviation / character
explain
0000 0000
0
0
00
NUL(null)
Null character
0000 0001
1
1
01
SOH(start of headline)
Title start
0000 0010
2
2
02
STX (start of text)
Text begins
0000 0011
3
3
03
ETX (end of text)
End of text
0000 0100
4
4
04
EOT (end of transmission)
End of transmission
0000 0101
5
5
05
ENQ (enquiry)
request
0000 0110
6
6
06
ACK (acknowledge)
Receive notice
0000 0111
7
7
07
BEL (bell)
Ring the bell
0000 1000
10
8
08
BS (backspace)
Backspace
0000 1001
11
9
09
HT (horizontal tab)
Horizontal tabs
0000 1010
12
10
0A
LF (NL line feed, new line)
Line feed key
0000 1011
13
11
0B
VT (vertical tab)
Vertical tabs
0000 1100
14
12
0C
FF (NP form feed, new page)
Page feed key
0000 1101
15
13
0D
CR (carriage return)
Enter key
0000 1110
16
14
0E
SO (shift out)
No switching
0000 1111
17
15
0F
SI (shift in)
Enable Toggle
0001 0000
20
16
10
DLE (data link escape)
Data link escape
0001 0001
21
17
11
DC1 (device control 1)
Equipment control 1
0001 0010
22
18
12
DC2 (device control 2)
Equipment control 2
0001 0011
23
19
13
DC3 (device control 3)
Equipment control 3
0001 0100
24
20
14
DC4 (device control 4)
Equipment control 4
0001 0101
25
21
15
NAK (negative acknowledge)
Refuse to accept
0001 0110
26
22
16
SYN (synchronous idle)
Sync idle
0001 0111
27
23
17
ETB (end of trans. block)
End transfer block
0001 1000
30
24
18
CAN (cancel)
Cancel
0001 1001
31
25
19
EM (end of medium)
Media end
0001 1010
32
26
1A
SUB (substitute)
Instead of
0001 1011
33
27
1B
ESC (escape)
Change the code ( overflow )
0001 1100
34
28
1C
FS (file separator)
File separator
0001 1101
35
29
1D
GS (group separator)
Grouping
0001 1110
36
30
1E
RS (record separator)
Record separator
0001 1111
37
31
1F
US (unit separator)
Cell separator
0010 0000
40
32
20
(space)
Space
0010 0001
41
33
21
!
exclamation mark
0010 0010
42
34
22
"
Double quotes
0010 0011
43
35
23
#
Well No
0010 0100
44
36
24
$
Dollar symbol
0010 0101
45
37
25
%
Percent sign
0010 0110
46
38
26
&
And no.
0010 0111
47
39
27
'
Closed single quotation mark
0010 1000
50
40
28
(
Open bracket
0010 1001
51
41
29
)
close-quote
0010 1010
52
42
2A
*
asterisk
0010 1011
53
43
2B
+
plus
0010 1100
54
44
2C
,
comma
0010 1101
55
45
2D
-
minus sign / Dashes
0010 1110
56
46
2E
.
Full stop
00101111
57
47
2F
/
Slash
00110000
60
48
30
0
Numbers 0
00110001
61
49
31
1
Numbers 1
00110010
62
50
32
2
Numbers 2
00110011
63
51
33
3
Numbers 3
00110100
64
52
34
4
Numbers 4
00110101
65
53
35
5
Numbers 5
00110110
66
54
36
6
Numbers 6
00110111
67
55
37
7
Numbers 7
00111000
70
56
38
8
Numbers 8
00111001
71
57
39
9
Numbers 9
00111010
72
58
3A
:
The colon
00111011
73
59
3B
;
A semicolon
00111100
74
60
3C
<
Less than
00111101
75
61
3D
=
Equal sign
00111110
76
62
3E
>
Greater than
00111111
77
63
3F
?
question mark
01000000
100
64
40
@
Email symbol
01000001
101
65
41
A
Capital A
01000010
102
66
42
B
Capital B
01000011
103
67
43
C
Capital C
01000100
104
68
44
D
Capital D
01000101
105
69
45
E
Capital E
01000110
106
70
46
F
Capital F
01000111
107
71
47
G
Capital G
01001000
110
72
48
H
Capital H
01001001
111
73
49
I
Capital I
01001010
112
74
4A
J
Capital J
01001011
113
75
4B
K
Capital K
01001100
114
76
4C
L
Capital L
01001101
115
77
4D
M
Capital M
01001110
116
78
4E
N
Capital N
01001111
117
79
4F
O
Capital O
01010000
120
80
50
P
Capital P
01010001
121
81
51
Q
Capital Q
01010010
122
82
52
R
Capital R
01010011
123
83
53
S
Capital S
01010100
124
84
54
T
Capital T
01010101
125
85
55
U
Capital U
01010110
126
86
56
V
Capital V
01010111
127
87
57
W
Capital W
01011000
130
88
58
X
Capital X
01011001
131
89
59
Y
Capital Y
01011010
132
90
5A
Z
Capital Z
01011011
133
91
5B
[
Square bracket
01011100
134
92
5C
\
The backslash
01011101
135
93
5D
]
Closed square bracket
01011110
136
94
5E
^
De character
01011111
137
95
5F
_
Underline
01100000
140
96
60
`
Open quotation mark
01100001
141
97
61
a
Lowercase letters a
01100010
142
98
62
b
Lowercase letters b
01100011
143
99
63
c
Lowercase letters c
01100100
144
100
64
d
Lowercase letters d
01100101
145
101
65
e
Lowercase letters e
01100110
146
102
66
f
Lowercase letters f
01100111
147
103
67
g
Lowercase letters g
01101000
150
104
68
h
Lowercase letters h
01101001
151
105
69
i
Lowercase letters i
01101010
152
106
6A
j
Lowercase letters j
01101011
153
107
6B
k
Lowercase letters k
01101100
154
108
6C
l
Lowercase letters l
01101101
155
109
6D
m
Lowercase letters m
01101110
156
110
6E
n
Lowercase letters n
01101111
157
111
6F
o
Lowercase letters o
01110000
160
112
70
p
Lowercase letters p
01110001
161
113
71
q
Lowercase letters q
01110010
162
114
72
r
Lowercase letters r
01110011
163
115
73
s
Lowercase letters s
01110100
164
116
74
t
Lowercase letters t
01110101
165
117
75
u
Lowercase letters u
01110110
166
118
76
v
Lowercase letters v
01110111
167
119
77
w
Lowercase letters w
01111000
170
120
78
x
Lowercase letters x
01111001
171
121
79
y
Lowercase letters y
01111010
172
122
7A
z
Lowercase letters z
01111011
173
123
7B
{
Flowering bracket
01111100
174
124
7C
|
vertical
01111101
175
125
7D
}
Closed curly bracket
01111110
176
126
7E
~
The waves,
01111111
177
127
7F
DEL (delete)
Delete

Python note · Chapter two —— Python The coding problem ( One ) More articles about

  1. [Python note ][ Chapter two Python Sequence - Complex data structures ]

    2016/1/27 Learning content Chapter two Python Sequence - Complex data structures Pile up import heapq # Add elements to the heap heapq.heappush(heap,n) # The top of the pile heapq.heappo ...

  2. [Python note ][ Chapter two Python Sequence -tuple,dict,set]

    2016/1/27 Learning content Chapter two Python Sequence -tuple tuple Created tips a_tuple=('a',), To create , instead of a_tuple=('a'), The latter is a creation of a character tup ...

  3. [python note ][ Chapter two Python Sequence -list]

    2016/1/27 Learning content Chapter two Python Sequence -list list Common operations list.append(x) list.extend(L) list.insert(index,x) list.rem ...

  4. Python note &#183; Chapter one —— Python Basics ( One )

    One .Python An introduction to the 1.Python The origin and version of 1.1 python The origin of python Founded by Guido · Van rosum (Guido van Rossum).1989 Christmas period of , Guido · Van rosum ( chinese ...

  5. [Python note ][ Chapter one Python Basics ]

    2016/1/27 Learning content Chapter one Python Basics Python Built in functions see Python Built in functions .md del command Explicit delete operation , You can also use . Basic input and output input() Characters are always read in ...

  6. Python self-taught : Chapter two Python zen

    >>print import <Python zen >, Tim · Peters Beauty is better than ugliness . Explicit is better than implicit . Simplicity is better than complexity . Complexity is better than complexity . Flat is better than nested . Sparse is better than dense . Readability count . ...

  7. Chapter two Python introduction

    Chapter two Python introduction 2.1. brief introduction Python It's famous " Uncle GUI "(Guido van Rossum) stay 1989 During Christmas , A programming language written to kill the boring Christmas Pytho ...

  8. Android Qunying notes —— Chapter two :Android New contacts for development tools

    Android Qunying notes -- Chapter two :Android New contacts for development tools In fact, there is nothing to talk about in this chapter , The front installation Android studio We can just skip , If you're interested , You can check it out Google main -Andr ...

  9. 《DOM Scripting》 Learning notes -—— Chapter two js grammar

    <Dom Scripting> Learning notes Chapter two Javascript grammar Content of this chapter : 1. sentence . 2. Variables and arrays . 3. Operator . 4. Conditional statements and loop statements . 5. Functions and objects . sentence (stat ...

Random recommendation

  1. 10.11 install pod

    Original address :http://www.jianshu.com/p/5fc15906c53a   thank . updates 10.11 cocoapods The easiest way to fix a problem This is because 10.11 hold cocoapods ...

  2. python Multi layer decorator

    25. Multi layer decorator :      1. principle : The execution order is from top to bottom ,#2 and #3 Make up a function and assume that nf1,#1 and nf1 Make up a function nnf1           f1 Become ck_ty_of_us Of inner The function is nf ...

  3. [Angular 2] Build a select dropdown with *ngFor in Angular 2

    We want the start-pipe more flexable to get param, so when using it, we pass a second param as statu ...

  4. matlab Save your drawing

      matlab The ability of drawing and visualization is needless to say , It can be said that it is a household name in the industry .Matlab Provides a wealth of drawing functions , such as ez** Simple drawing function of system class ,surf.mesh System class of numerical drawing function, etc . Other professionals ...

  5. Maven Installation and use

    http://repo.spring.io/release/org/springframework/spring/ Installation configuration :https://segmentfault.com/a/1190000003 ...

  6. oracle Group by a field and take the largest record from each group

    demand : Query each device for defects that have not been eliminated , Take the one with the highest defect level , As the current defect level of this device : data source : select t.device_id, t.defect_level from sp_pd_defect ...

  7. Struts2 And Action Receive request parameters and interceptors

    Technical analysis is Struts2 Use... In the framework Servlet Of API        1. stay Action Class can also get Servlet Some commonly used API        * demand : Provide JSP The data of the form page , stay Ac ...

  8. open-falcon Agent Configuration file modification hostname after , There are other names endpoint

    problem open-falcon Agent Modify the configuration file hostname after ,log Other names were found in the log endpoint. reason Graph, Gateway Components Reference goperfcounter(gi ...

  9. python --- mulitprocessing( Multi process ) Module USES

    1. What is a process ? process (Process) A program in a computer is about a running activity on a data set , Is the system resource allocation and scheduling of the basic unit , Is the foundation of the operating system architecture . In early process oriented computer architecture , Process is the basic execution of a program ...

  10. UOJ207: We're going to visit Changsha together

    Topic UOJ Sol Divine topic Give each pair of points a random weight , XOR the weight of these two points to the random value use \(LCT\) Maintain subtree information , If the XOR sum of subtrees is the XOR sum of all pairs of points, then it is the answer Big constant code # include < ...