python3 报错: AttributeError: 'module' object has no attribute 'urlopen'

来源:互联网 发布:xls导入sqlserver 编辑:程序博客网 时间:2024/04/29 05:07

python3 中import urllib之后应用的时候会报错:

httpcode=urllib.urlopen(‘www.baidu.com’)


错误: AttributeError: 'module' object has no attribute 'urlopen'


经过查询python文档得知,在python3中urllib方法变化了一些:

https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen


更改成:import urllib.request

httpcode = urllib.request.urlopen(m)

则可以运行成功。 

0 0