About Python file IO

 

Using the Open function,

The first parameter is the file name,
such as "C: \ abc.txt", to note here is that r "C: \ abc.txt".

The second parameter is the mode of operation of the file,
here focuses on written,
is written mainly divided into overwrite and append writing.

Overwrite examples:

= Open File (r'C: \ named abc.txt ',' W ')
a file.write ( "ABC") # write the string
file.close # File Close

Additional written examples:

= Open File (r'C: \ named abc.txt ',' A ')
a file.write ( "ABC") # write the string
file.close # File Close

Using the Open function,

The first parameter is the file name,
such as "C: \ abc.txt", to note here is that r "C: \ abc.txt".

The second parameter is the mode of operation of the file,
here focuses on written,
is written mainly divided into overwrite and append writing.

Overwrite examples:

= Open File (r'C: \ named abc.txt ',' W ')
a file.write ( "ABC") # write the string
file.close # File Close

Additional written examples:

= Open File (r'C: \ named abc.txt ',' A ')
a file.write ( "ABC") # write the string
file.close # File Close

Guess you like

Origin www.cnblogs.com/miliam-12/p/11689750.html