Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://repl.it/languages/python3
- import urllib.request
- import urllib.parse
- import urllib.error
- fhand = urllib.request.urlopen('http://data.pr4e.org/romeo.txt')
- counts = dict()
- for line in fhand:
- print(line.decode().strip())
- words = line.decode().split()
- for word in words:
- counts[word] = counts.get(word, 0) + 1
- print(counts)
Advertisement
Add Comment
Please, Sign In to add comment