python-3.x - 无法使用 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)
解决方案
推荐阅读
- pandas - 如何根据列上的条件在数据框中执行嵌套的 groupby 操作?
- excel - 对象“_Worksheet”的方法“范围”失败 |Excel|VBA|
- go - 将 Goroutine 分离为独立进程
- html - 仅在chrome下两个div在同一位置时的垂直空间错误
- regex - 除了 ?和 *,条件格式中允许使用哪些其他通配符?
- python - 如何使用 Python 在 XML 中修改具有相同标签的不同值?
- php - 从 PHP 数组中获取逗号分隔值
- excel - 从关闭的工作簿中动态复制单元格范围?
- mysql - 避免表扫描并在查询中使用索引
- swift - 符合 'CBCentralManagerDelegate' 协议