The Read () method reads the entire file and returns the entire file as a string.
The ReadLine () method reads only one line at a time, one line at a time, per run. If you want to read the entire file, you need to combine loops to determine the end of the file.
Python determines that the flag at the end of the file is read to a null character.
Like what:
While str! = ": ReadLine ()
Instead, ReadLines () reads the entire file, returns it as a list, and takes each line of the file as an element of the list.
The Write (str) parameter is a string that writes a string to the file.
Writelines (SEQ) provides parameters that can iterate over objects, such as lists, to write a list to a file. Similar to writing to each element called write (str) writes the file.
After writing the file, you need to call flush () to persist to the disk.
This article is from the Linux and networking blogs, so be sure to keep this source http://khaozi.blog.51cto.com/952782/1769531
Python file Read and write method: Read ReadLine readlines wirte writelines