creating file
I do not know the mode of opening file "R" mode or "w" mode I tried with these two modes But I am little bit confuse in these two modes.
CodePudding user response:
You'll find all the information on file mode in the documentation here.
r
stands for read mode, it's the default mode so you don't need to specify it you just want to read the file.
w
stands for write mode, use if you want to write to the file.
Example :
f = open("foo.txt")
content = f.read()
You should care about errors that can occur : file not found, not readable, not enough permission, ...
But that's another story.
CodePudding user response:
You can open the file in write mode by writing f=open("f.txt", "w") and in read mode by writing f=open("f.txt", "r")