python学习笔记之爬取网页乱码
程序员文章站
2024-01-02 18:02:52
...
encodings = requests.utils.get_encodings_from_content(page.text) //获取page内容编码 page.encoding="utf-8" //用utf-8解码网页内容 f = open("D:\\python\\a.txt","a+",encoding="utf-8") //设置读写文件所用编解码格式