 |  |

 |
 |  |  |
 | Welcome to CS1315. Click on the python to add comments.
|  |
 |  |  |
|
This page removed for FERPA compliance
|
        |
function that reads contents of a text file
# Return the contents of the named text file
def fileContents(filename):
# Get the file object that corresponds to the file name
# We open it for reading as a text file. (We could also
# open binary files REMOVEDing "b" instead of "t" and we could
# open for writing, REMOVEDing "w" instead of "r")
fileObject = open(filename, "rt")
# Get the (possibly very long) text string that the file
# contains by reading it
contents = fileObject.read()
return contents
Link to this Page