vp主机:有时候使用python从网站上爬数据的时候,如果数据里包含中文,有时候显示的却是如下所示...\xe4\xba\xba\xef\xbc\x8c\xe6...类似与国际化
解决方法
import urllib.request import sys weburl="..." webhead=... req=urllib.request.Request(url=weburl,headers=webhead) response=urllib.request.urlopen(req) content = response.read() #获得系统的编码 type = sys.getfilesystemencoding() #设置爬出内容的编码 content = content.decode(type) file = open("c。txt",'w',10000) file.write(str(content)) file.close() print(content)
Copyright © 2013-2023 . All Rights Reserved. 宵云 版权所有 南通宵云网络科技有限公司
工信部备案:苏ICP备18049042号-2 公安部备案:苏公网安备 32060102320703号
《中华人民共和国增值电信业务经营许可证》经营性ICP/ISP/IDC三证:苏B1.B2-20210805