📜  如何在 python 代码示例中将 utf-16 文件转换为 utf-8

📅  最后修改于: 2022-03-11 14:47:21.152000             🧑  作者: Mango

代码示例1
with open(ff_name, 'rb') as source_file:
  with open(target_file_name, 'w+b') as dest_file:
    contents = source_file.read()
    dest_file.write(contents.decode('utf-16').encode('utf-8'))