The arguments of file open? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

The arguments of file open?

Arguments like r, w, a, wb, rb are there, but I want to exact difference between write and append

25th Apr 2017, 4:47 PM
BASKARAN C
BASKARAN C - avatar
3 Answers
+ 1
write overwrites the contents of the file (essentially creates a new file), append keeps the existing content (begins at the last line of the file).
25th Apr 2017, 5:51 PM
Mason Krei
Mason Krei - avatar
0
Here are the opening modes: r -> read w -> write (if file doesn't exist, create it, otherwise, empty it) a -> appends at the end of the file b -> binary mode, useful i f you use something like pickle there is also: + -> update (not recommended, you have full access to the file in read/write mode) x -> creates the file. If it already exists, throws an error
25th Apr 2017, 8:58 PM
Amaras A
Amaras A - avatar
0
Would you be so kind as to mark my response as the answer? This is the check mark next to my response. Thank you.
28th Apr 2017, 6:10 PM
Mason Krei
Mason Krei - avatar