Oct-13-2017, 03:42 PM
Open a file and read it.
with open('file.txt', 'r') as f: words = f.read() # all file data will be into 'words'Open a file for writing:
with open('file.txt', 'w') as f: f.write(words) # write the data into the fileBoth operations will close the file after the with code block ends.