编码方式缺省的是ANSI,可以选择Unicode/Unicode big endian/UTF-8
open(file_path, "r", "utf-8") as utf_file: content = utf_file.read() # 将内容以ANSI编码写回文件 with codecs.open(file_path, "w", "ansi") as ansi_file: ansi_file.write(content) print("已成功将文件 {} 转换为ANSI编码".format(file_path)) except Exception as e: print("转换...