So I've been messing around with write.
In my folder, I have a text file called test.txt which contains abcdefg.
If I run the following script:
with open('test.txt', mode='r+') as f:
f.write('test')
the test.txt file now contains testefg
And for some reason, if I instead run the following script: (starting back with abcdefg in test.txt)
with open('test.txt', mode='r+') as f:
f.read()
f.write('test')
Now the test.txt file contains abcdefgtest
Also, I don't really understand what mode='r+' does because I can't find it in any documentation. Some sources on the internet said that it was for both reading and writing in the file. I suspect it behaves the same as '+'