Initial encoding
The transmission of the computer, and the actual storage is 01010101010.
USA: ASCII code can only represent 256 possible, too few
In order to solve this global problem of writing, the creation of the universal Code, Unicode
There are more than 90,000 words in Chinese, 16 bits indicates that one character is not enough, 32 bits represents one character
A 0100 0001 0100 0001 0100 0001 0100 0001
ASCII code: 1 bytes for all English, special characters, numbers, etc.
Unicode:2 bytes, 16 bits means one Chinese, not enough. Unicode one Chinese is expressed in four bytes
Unicode Upgrade Utf-8 (a Chinese to be represented in 3 bytes) utf-16 utf-32
00000001 8-bit = = 1 bytes byte
1byte 1024byte = = 1kb
1kb 1024KB = = 1MB
1MB 1024MB = = 1GB
1GB 1GB = = 1YB
Utf-8 a character at least 8 bits to indicate:
English is represented by 8 bits of a byte
European writing with 16-bit to represent two bytes of representation
Chinese with 24-bit to represent three bytes of representation
Utf-16 a character at least 16 bits to indicate
GBK domestic use, a Chinese with two bytes (Chinese-made, can only be used in Chinese and ASCII code text)
GBK and Utf-8 can only be interchanged by Unicode.
basic data type for 1.Python (INT,BOOL,STR)
- int ==> integers are primarily used for mathematical operations
- STR ==> string can save a small amount of data and do the corresponding operation
- Boolè Boolean value to determine true, false
- The Listè list stores a large amount of data, using [] to denote Z ["Tai Yang elder brother", "Dongyang elder brother",]
- Tupleè Ganso can not be changed, the tuple is represented by (). Read-only list, cannot be changed
- Dictè dictionary holds key-value pairs, as well as saving a large number of
- The set collection holds a large amount of data and cannot be duplicated, in fact, the dict of the value is not saved.
2. Integer (int)
All integers in Python3 are of type int. But in Python2 if the amount of data is larger. A long type is used. There is no long type in Python3
Bit_length () calculates the length of the binary code that an integer occupies in memory
3. Boolean value (BOOL)
BOOL Type conversions:
1. What you want to convert into. Just wrap the target with something.
2. Null is False, true without empty
The value is only true, False. BOOL value does not operate.
Conversion issues:
str = = int int (str)
int = str str (int)
int = bool bool (int). 0 is false, not 0 is true
Bool=>int Int (BOOL) True is 1, false is 0
str = = bool bool (str) empty string is false, not NULL is true
bool = str STR (BOOL) converts the bool value to the corresponding "value"
4. String (str) (emphasis)
in the python in use ' , ', ' ', ' "" What is cited is called a string. .
4.1
slices and indexes
1. index :
Index is subscript . Remember , Subscript from 0 start.
Start position subscript is 0(left to right),1(right to left)
4.2. slices:
slices are indexed by ( index: index: Step ) intercept a paragraph of a string to form a new string
Principle: Gu Tou disregard the tail
4.2.1 in sequential (left-to-right or right-to-left) syntax:str[start:end]
2.2 jump and intercept.
Step Size : if it is an integer , then take it from left to right . if it's a negative number . then take it from right to left . default is 1
Slice syntax:
Str[start:end:step] Start: Starting position end: End Position Step: Step
The manipulation of strings
Remember , string are immutable objects , so any action on the original string It won't have any effect.
Initial code for the third day of Python, basic data type