解决网页抓取乱码问题
解决: 导入gzip解压方法 import urllib.request from io import BytesIO import gzip url = 'http://www.mzitu.com' response = urllib.request.urlopen(url) html = response.read() print(html) buff = BytesIO(html) f = gzip.GzipFile(fileobj=buff) res = f.read().decode('utf-8') print(res)