Skip to content

Instantly share code, notes, and snippets.

@dustinsgoodman
dustinsgoodman / PythonIO.py
Created May 7, 2013 03:22
An example of using file input and output.
#example file writing procedure
f = open("/home/sharocko/Documents/Codecademy/output.txt", "w") #open the file for writing
f.write("Hello World\n") #write a string to the file
f.close() #close the file when we're done
#example file reading procedure
f = open("/home/sharocko/Documents/Codecademy/output.txt", "r") #open the file for reading
print f.read() #read data from the file
f.close() #close the file when we're done