标签:logs park dir codec 目录 out list pen 编码
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)
标签:logs park dir codec 目录 out list pen 编码
原文地址:http://www.cnblogs.com/LicwStack/p/6877817.html