Python-Ref > Using files > Reading and writing files > Appending to a file
 
 

<-^^
Klíčová slova
Moduly
Knihovní funkce

Appending to a file

To append data to a file, the approach from Writing files can be used, with a small change in the call to file. In case of appending, the mode is not w but a.
Expand/Shrink
This is an example text in an example file.
It even has
several
lines.
Zdroj: (fileio7-1.py)
  1   f = file( "example.txt", "a")   # open file "example.txt" for "a"ppending
  2   
  3   f.write("Hi there.")        # write something to the file
  4   f.write("How do you do?")   # write something more
  5   
  6   f.close()  # close the file
Doba běhu: 20.4 ms