I tried to use both of them opening a file but got the same result.
w+
is supposed to create a new file if it doesn't exist while r+
not.
Is this the only difference?
For example, this is an initial file file.txt
Line 1
Line 2
Line 3
1) file.txt
after implementing of r+
mode (writing the word "hello")
hello
2) file.txt
after implementing of w+
mode
hello
I guessed that r+
would append an input to the beginning of the file.
EDITED: So, the 1st difference is about creating a file that doesn't exist and the 2nd difference is that r+ overwrites while w+ truncates, right? (than the question arises whether overwriting and truncating are the same concepts or not)