Character encoding
Understanding the storage knowledge of character encoding
Basic Computer knowledge
1. Three core hardware of computer running program
CPU--------calculation, running program memory---------Fast, the power-on disk-------permanent storage, slow read and write speed
Any operation must first be loaded from the hard disk into memory and then executed by the CPU-to-memory call
function of the operating system: 1 Control Hardware 2. Provide system call interface for software
Operating System management software, the application system through the operating system indirect operation of the hardware, such as computer power on, the first boot operating system (on the hard disk) and then the operating system code loaded into memory, the CPU call execution, the operating system officially started running.
2. How the text editor accesses the file (Nodepad++,pycharm,word)
Opening the editor opens a process that is in memory, so content written in the editor is also stored in memory, and data is lost after a power outage
So you need to save to your hard drive and click the Save button to swipe the data from memory to your hard drive.
At this point, we write a py file (no execution), no different from writing other files, just writing a bunch of characters.
3 . How the Python interpreter executes the py file, such as Python test.py
First stage: The Python interpreter starts, which is equivalent to launching a text editor
The second stage: the Python interpreter equivalent to the text editor, to open the test.py file, from the hard disk to read the contents of the test.py file into memory ( Small review: Pyhon interpretation, decided that the interpreter only care about the contents of the file, do not care about the file suffix name)
Phase three: The Python interpreter interprets the code that executes just loaded into memory test.py ( PS: In that phase, when executed, the Python syntax is recognized, execution of the in-file code executes to Name= "Egon", which will open up memory space to hold the string "Egon")
Summary: The similarities and differences of the Python interpreter in the document editor
same point: The Python interpreter interprets the contents of the executable file, so the Python interpreter has the ability to read the Py file, as is the case with a text editor
different points: The text editor reads the contents of the file into memory for display/editing, and the Python interpreter reads the contents of the file into memory for execution (recognizing Python syntax)
Converts a person's known character to a computer-readable binary number
Character--------(translation process)-------> numbers
This process is actually how a character corresponds to the standard of a particular number, which is called a character encoding.
The history of the character reading coding
For all countries to use the computer, the same set of Unicode, unified 2Bytes for a character, 2**16-1=65535, can represent more than 60,000 characters, thus compatible with the universal language
1bytes=8bit,,8bit can represent a change of 0-2**8-1, which can represent 256 characters
Python's character encoding