python3中的urllib
#python3的urllib2和urllib合并了 #import urllib2会报错 import urllib.request #直接请求 response = urllib.request('http://www.baidu.com') #获取状态码,如果是200表示成功 print(response.getcode()) #读取内容 cont=response.read()
报错'module' object is not callable
换成
response = urllib.request.Request('http://www.baidu.com')
报错 'Request' object has no attribute 'getcode'
https://www.jianshu.com/p/1c10e6b36dd4