File is nothing but readable, writable, executable operation, corresponding to the mode R, W,x, read-only mode, write-only mode, only the mode of execution, a mode for Append mode, the actual write operation mode, r+,w+,a+ can read and write mode, the following detailed mode usage
1, mode usage of the file
R file does not exist will be an error
The W file does not exist and is created, but empties the contents of the file, writes the new content
A file does not exist and is created, but there is already a file append content
2, write operation of the file
The write operation of the file must be written in W mode in a mode,
Operation method
F=open (' Www.96net.com/robot.txt ', ' W ', encoding= ' utf-8 ')
F.write (' aaaaaaaaaaaaaa ')
F.close ()
3, the file's W mode and a mode difference
W file empties the previous content, writes content to the file
R file does not empty previous content, append content to File
Article from (http://www.96net.com.cn/)
Python learns 21 days file readable, writable, actionable action