最近在处理Excel文件中,报错:openpyxl.utils.exceptions.IllegalCharacterError,

  原因是某字段出现特殊字符 \x05,\x06,\x07如下图:

  在Excel文件中显示 如下

  python3  特殊字符处理 \x06\x05\x07

  内存中显示

 python3  特殊字符处理 \x06\x05\x07

  python3  特殊字符处理 \x06\x05\x07

 

 

  python3  特殊字符处理 \x06\x05\x07

    

  因此在代码中需要把\x06,\x05,\x07替换掉才行

  txt = txt.replace("\x06", "").replace("\x05", "").replace("\x07", "")

  这样保存就没有问题了。

相关文章:

  • 2021-06-12
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-12
  • 2021-11-27
  • 2022-01-23
  • 2022-02-07
  • 2022-02-17
  • 2021-12-09
  • 2021-12-19
相关资源
相似解决方案