ANSI编码的文件转为UTF-8编码的文件。

# ANSI文件转UTF-8
import codecs
import os

# 文件所在目录
file_path = "H:\Python\South.Park.S02.WEB-DL.chs"
files = os.listdir(file_path)

for file in files:
    file_name = file_path + '\\' + file
    f = codecs.open(file_name, 'r', 'ansi')
    ff = f.read()
    file_object = codecs.open(file_path + '\\' + file, 'w', 'utf-8')
    file_object.write(ff)

  

相关文章:

  • 2022-12-23
  • 2021-06-28
  • 2022-02-18
  • 2021-10-23
  • 2022-12-23
  • 2022-02-25
  • 2021-09-01
猜你喜欢
  • 2022-02-14
  • 2022-12-23
  • 2022-03-09
  • 2022-12-23
  • 2021-11-17
  • 2021-07-30
  • 2022-12-23
相关资源
相似解决方案