下面的代码作用是修改文件的编码格式。代码很简单,但是也很牛逼(在我看来),这是在segment上找到的解决办法,废话不多说,直接上代码。
import codecs

def ReadFile(filePath, encoding):
    with codecs.open(filePath, "r", encoding=encoding) as f:
    return f.read()

def WriteFile(filePath, content, encoding):
    with codecs.open(filePath, "w", encoding=encoding) as f:
    f.write(content)

def UTF8_to_GBK(src, dst):
    content = ReadFile(src, encoding="gbk")
    WriteFile(dst, content, "utf-8")

 

 

 

相关文章:

  • 2021-10-01
  • 2022-12-23
  • 2021-11-03
  • 2022-12-23
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
猜你喜欢
  • 2022-12-23
  • 2021-11-29
  • 2021-09-20
  • 2021-09-29
  • 2022-12-23
  • 2021-10-20
  • 2021-05-28
相关资源
相似解决方案