昨天用用python3写个日志文件,结果报错UnicodeEncodeError: 'gbk' codec can't encode character '\xa0' in position 30: illegal multibyte sequence

  具体代码是:

  with open(fileName, 'a') as f:

    f.write(message)

  后来改成如下:

  with open(fileName, 'a',encoding='utf-8') as f:

    f.write(message)

  就可以了。还是编码的问题

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-09
  • 2022-02-04
  • 2021-10-17
  • 2021-12-25
  • 2021-09-02
  • 2022-12-23
相关资源
相似解决方案