Accessing Files (r+ or w+)
Posted: Mon Apr 24, 2017 9:51 am
I use the book by Mike McGrath - Python in Easy Steps.
I find this book is excellent and in it (on page 106) he describes the commands to open files and how to read or write.
file = open ('example.txt' , 'r+')
This command is described as "Open a text file to read from or write to"
file = open ('example.txt' , 'w+')
This command is described as "Open a text file to write to or read from"
Could someone please advise me what is the difference and when each one is used, as they seem to be the same to me (apart from the obvious).
I find this book is excellent and in it (on page 106) he describes the commands to open files and how to read or write.
file = open ('example.txt' , 'r+')
This command is described as "Open a text file to read from or write to"
file = open ('example.txt' , 'w+')
This command is described as "Open a text file to write to or read from"
Could someone please advise me what is the difference and when each one is used, as they seem to be the same to me (apart from the obvious).