Reputation: 277
For a newly created file, is there any difference between write() and append() methods, in Python?
Upvotes: 2
Views: 5518
Reputation: 6642
When you open a file in append mode, the seek pointer points to the end of the file (the pointer position will be non-zero if the file is not empty).
On new (empty) files, the end is equal to the beginning. So appending is the same as overwriting.
Upvotes: 1
Reputation: 303
The write
method overwrites the content in a text file while the append
method appends text to the file.
If there is nothing in the file however, then write
is the same as append
(they both write new text into the file).
Upvotes: 3