1.window operating system with the encoding format is GBK,PYTHON3 encoding format is utf_8;
2. File Stream Processing
Get the file handle through open (), manipulate the operating system through the handle to read the contents from the document, and then close the handle when the document information is read, or it will always occupy the operating system.
R mode: read-only mode
F.read ()//Read all the contents of the document
F.readlines ()//Read the entire contents of the document
F.readline ()//read a line of content in the document, return a list
Print (F.readline (), end = ")//end =", remove blank lines after printing
F.readable ()//Determine if the file is readable
3. File Write operations
File write operation, in the case of a file already exists, will clear all the contents of the file, and then add content to the file, if the file does not exist, create a new file, and then write the contents to the file.
Write String
4. Append content actions to the end of the document: a mode
5. File read/write mode
Note: The file is stored on the hard disk, the file can not be modified by nature, the modified file is through the software, in memory to modify the file, and then save the modified content to the new file. If the modified content is saved in the original file, the previous content is overwritten.
The file write operation always starts at the position of the pointer and overwrites the content behind it.
6. Use the with operation to close the file without manually writing close ()
7. Open two files at the same time, read the information from one file, write this information to another file
Python file processing