python edit txt file code example
Example 1: python edit text file
with open("foo.txt", "a") as f:
f.write("new line\n")
Example 2: how to veiw and edit files with python
#write
f = open('helloworld.txt','wb')
f.write('hello world')
f.close()
#read
f = open('helloworld.txt','r')
message = f.read()
print(message)
f.close()