f = open("a.txt","w")  


,在windows下面,新文件的默认编码是gbk,这样的话,python解释器会用gbk编码去解析我们的网络数据流txt,然而txt此时已经是decode过的unicode编码,这样的话就会导致解析不了,出现上述问题。 解决的办法就是,改变目标文件的编码:


f = open("a.txt","w",encoding='utf-8')  

 

相关文章:

  • 2022-12-23
  • 2022-03-02
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2021-05-17
猜你喜欢
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
相关资源
相似解决方案