Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

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 using "b" instead of "t" and we could
  # open for writing, using "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