python read the file and write the contents to a file

Read the contents of the file :

# Reads the contents of the file and press newline slicing 
Lines = Open ( " Data / voc01.txt " , encoding = " UTF-. 8 " ) .read (). Split ( " \ n- " )

 

Write to the file:

# Additionally written to the specified file 
STR = " ABCD " 
with Open ( ' E: /test/test_en.txt ' , MODE = ' A + ' , encoding = " UTF-. 8 " ) W AS: 
     w.write (STR + " \ the n- " )

 

Guess you like

Origin www.cnblogs.com/jumpkin1122/p/11516956.html