endswith(".txt"): file_path = os.path.join(root, file) try: #以UTF-8读取文件内容 with codecs.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(...