09_3_read_and_write - # where it should go) def...

# Reading and writing files. .. # readAndPrint reads the contents of a text file and prints it out # to command area def readAndPrint(filename): pass # inputAndWrite gets some text from a user and then writes it out to file def inputAndWrite(filename): pass # readAndWrite makes a copy of a text file named "temp.bak" in the same # folder as the original. def readAndWrite(filename): pass # downloadAndPrint is like readAndPrint but works for a web address, # not a local file name def downloadAndPrint(url): pass # downloadAndWrite makes a copy of a web page's source in a local file # (This time the file name has to be fully qualified, so we need the folder

This is the end of the preview. Sign up
to
access the rest of the document.

Unformatted text preview: # where it should go) def downloadAndWrite(url, folder): pass # Get the path of a full filename. # Don't worry how this works for now. Just use it as though it were built # into JES. # # Examples: # # E.g (Macintosh) # &gt;&gt;&gt;getPath(&quot;/Users/potts/Documents/GT/ed/1315/temp.py&quot;) # &quot;/Users/potts/Documents/GT/ed/1315/&quot; # # E.g. (Windows) # &gt;&gt;&gt;getPath(&quot;C:\\My Documents\\GT\\ed\\1315\\temp.py&quot;) # &quot;C:\\My Documents\\GT\\ed\\1315\\&quot; def getPath(filename): from os import sep pathEnd=filename.rfind(sep) return filename[:pathEnd+1]...
View Full
Document