网易新闻爬取项目输出的txt文档出现乱码

Author: latioasCreated Jan 23, 2019Updated Dec 14, 2025

网易新闻爬取项目输出的txt文档出现乱码, 当15,16行做出如下修改后,输出的txt文档正常了。

    with open(path, "w+") as fp:
        for s in slist:
            print(s[0], s[1])                           
            fp.write("%s\t\t%s\n\n" %(s[0],s[1]))    

Source: lining0806/PythonSpiderNotes