09_3_read_and_write

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

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
# 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
Background image of page 1
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) # >>>getPath("/Users/potts/Documents/GT/ed/1315/temp.py") # "/Users/potts/Documents/GT/ed/1315/" # # E.g. (Windows) # >>>getPath("C:\\My Documents\\GT\\ed\\1315\\temp.py") # "C:\\My Documents\\GT\\ed\\1315\\" def getPath(filename): from os import sep pathEnd=filename.rfind(sep) return filename[:pathEnd+1]...
View Full Document

Ask a homework question - tutors are online