Course Hero Logo

unit6yp.py - ' 0.1. Write a program to list lines in the...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 3 out of 6 pages.

'''0.1. Write a program to list lines in the Huckleberry Finn filethatcontain a string of three asterisks. The file URL is:
0.2 Write a program that reads this same file from the web andcreates apersistent list of the lines in it.
finalLines.append(line)shelf = shelve.open('books')shelf['Huckleberry Finn'] = finalLinesshelf.close()'''0.3 Modify the previous program so that it does use a listcomprehension.'''import urllib.request, shelveurl = ''book = urllib.request.urlopen(url)lines = book.readlines()book.close()finalLines = [lines.decode()[:-2] for line in lines [21:11381]]shelf = shelve.open('books')

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 6 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
Epstein,Jeffrey
Tags

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture