how to open and write file in python code example
Example 1: python write to file
with open(filename,"w") as f:
f.write('Hello World')
Example 2: read and write to file python
file = open(“testfile.txt”, “r+”)
with open(filename,"w") as f:
f.write('Hello World')
file = open(“testfile.txt”, “r+”)