Python3下载文件:AttributeError:module 'urllib' has no attribute 'request'
文章目录
- python3的urllib包有了一些更新,在使用的时候要注意一下
1 | import os |
- 这样使用会报错
1 | AttributeError: module 'urllib' has no attribute 'request' |
- 因为在python3中
urllib.request
成为了一个独立的包, 所以在导入的时候要改为
1 | import os |
其他下载文件方法
1 | headers = {'Content-Type': "application/json"} |