python open to write to file code example
Example 1: python file open
#there are many modes you can open files in. r means read.
file = open('C:\Users\yourname\files\file.txt','r')
text = file.read()
#you can write a string to it, too!
file = open('C:\Users\yourname\files\file.txt','w')
file.write('This is a typical string')
#don't forget to close it afterwards!
file.close()
Example 2: python open and read file with
with open('pagehead.section.htm','r') as f:
output = f.read()