File operations in Python are simple as seen in the following example.
The open() method is used to open a file.
There are several operations that can be performed on the file. The most important ones are “w” for write, “a” for append, “r” for read.
Text files and binary files can be opened this way.
f = open("a1.txt", 'w')
f.write("Metric Coder")
f.close()
f = open("a1.txt", 'a')
f.write(" Bangalore ")
f.close()
f = open("a1.txt", 'r')
content = f.read()
print(content)
f.close()
The link to the Github repository is here .