将UTF-16转换为UTF-8并删除BOM?

将UTF-16转换为UTF-8并删除BOM?,第1张

将UTF-16转换为UTF-8并删除BOM?

只需使用

str.depre
str.enpre

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.depre('utf-16').enpre('utf-8'))

str.depre
将为您摆脱BOM表(并推断字节序)。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5644258.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存