1. response = urllib.request.urlopen(req)获取的response对象没有.content方法
代码如下:
报错界面如下:
response = urllib.request.urlopen() 所得到的这个response对象没有.content的类方法或属性。
分析如下:
应该使用response.read() 并且还需要解码 .decode('utf-8')
另外在with open () 打开文件时,没有指定encoding='utf-8'
另外,在文件保存命名上,应直接使用字符串topic,topic_url是编码后字符串,不方便辨识