首页 > 解决方案 > 无法使用 python 3.8.3 导入 urllib.request

问题描述

我正在尝试使用 cmd 行在我的 windows10 机器上运行以下代码,但输出是带有 ModuleNotFoundError 的 Traceback。我用 sublimtext3 编辑器编写了代码

#!/usr/bin/env python3

import urllib.request
fhand = urllib.request.urlopen('http://data.pr4e.org/romeo.txt')
counts = dict()
for line in fhand: [enter image description here][1]
    words = line.decode().split() 
for word in words: 
    counts[word] = counts.get(word, 0) + 1 
print(counts)

标签: python-3.xurllib

解决方案


推荐阅读