import urllib.request, urllib.parse, urllib.error

_response = urllib.request.urlopen("http://data.pr4e.org/romeo.txt")

print(type(_response))
print()

# 많이 사용하는 단어 출력하기 - 상위 10개 출력
counts = {}
for line in _response :
    print(line.decode().rstrip())

    for word in line.decode().rstrip().split() :
        counts[word] = counts.get(word, 0) + 1

print()

for k, v in sorted(counts.items(), key=lambda item:item[1], reverse=True)[0:10] :
    print("{:10} : {:>5}".format(k, v))



-------------------------------------------------------------
>>> exec(open("http.py", encoding="utf-8").read())
<class 'http.client.HTTPResponse'>

But soft what light through yonder window breaks
It is the east and Juliet is the sun
Arise fair sun and kill the envious moon
Who is already sick and pale with grief

is         :     3
the        :     3
and        :     3
sun        :     2
But        :     1
soft       :     1
what       :     1
light      :     1
through    :     1
yonder     :     1