1. Encoding
1. The earliest computer encoding is ASCII. Created by Americans. Contains the English alphabet (uppercase letters, lowercase letters). Special characters such as numbers, punctuation, etc. [email protected]#$%
128 code point 2**7 on this basis added a 2**8
8 bits. 1 bytes (byte)
2. GBK GB code 16 bit. 2 bytes (double-byte characters)
3. Unicode universal Code 32 bits, 4 bytes
4. Utf-8: English 8 bit 1 bytes
European Writing 16bit 2 bytes
Chinese 24bit 3 bytes
8bit = 1 byte
1024x768 byte = > 1kb
1024x768 = 1MB
1024MB = 1GB
1024GB = > 1TB
2. Overview of basic data types
int integer
STR string, storing a small amount of data
BOOL Boolean
List, ["Tai Yang elder brother", "Dongyang elder brother",]
Tuple tuples. Read-only list, cannot be changed
Dict dictionary; A pair of stored data. Key:value {"Zhao Yang": "Tai Yang elder brother", ' Jay ': "Jay Chou"}
Set set. Store non-duplicated content
3. int, bool, str
int method Operation:
Bit_length () to find the binary length
BOOL: type conversion
1. What you want to convert into. Just wrap the target with something.
2. Null is False, true without empty
Str
1. Str indexes and slices:
Index: Starting subscript is 0 (left to right), (-1) right to left
Slice: s[start position: End Position: Step]
Features: Gu Tou regardless of the tail
2. Common operations for strings: common methods
The string is immutable.
1. Upper () converted to uppercase
2. Strip () Remove space
3. Replace () replacement
4. Split () cut
5. Format () formatted output
6. StartsWith () Decide whether to start with XXX
7. Find (). No return-1 found
8. Len () built-in functions. Direct use. To find the length of a string without a point operation
3. Iteration
The for variable in can iterate over the object:
Loop body
Else
Python day-3 basic data types