1. Is and = = Difference
ID () function
Small Data pool (constant pool): Store the values we have used in the? Small data pool. For other variable quantities.
Small data pools are used for numbers and strings, and other data types do not exist.
For numbers: -5~256 is added to the small data pool. Each use is the same object.
For strings:
1. If it is plain text information and underscores. Then this object will be added to the data pool
2. If it is with a special character. Then it will not be added to the small data pool. Every time it's new.
3. If the case is a single letter *n. ' A ' *20, within 20 units is possible. More than 20 units will not be added to the? Small Data pool
s = ' Alex ' Print (ID (s)) # 4326667072
s = "Alex" Print (ID (s)) # 4326667072
S1 = "@1 2"
S2 = "@1 2"
Print (ID (S1))
Print (ID (s2))
# The results are consistent, but inconsistent in the terminal. So in Python, the command-line code and the code in the py file may run differently.
Summarize:
= = Determine the values on both sides
is to determine the memory address
Review code:
1. ASCII: English, special characters, numerals, 8bit, 1byte
2. GBK: Chinese 16bit, 2byte. Compatible with ASCII
3. Unicode: Universal code, 32bit 4byte. Compatible with ASCII
4. UTF-8: variable-length Unicode. English: 8bit, Europe: 16bit, Chinese: 24bit 3byte
Python2 can only be used in ASCII
Python3 has Unicode, the default encoding is Unicode
In memory, Unicode is used. Hard drives and network transmissions are utf-8 or GBK.
2. Encode () encoding. Gets the result after the encoding. bytes
3. Decode () decoding. Bytes programming our familiar strings
Python Sixth day