【发布时间】:2011-01-08 10:30:50
【问题描述】:
我有 utf16le (BOM) 编码的大文件。
是否可以通过python将其转换为通常的UTF8?
类似
file_old = open('old.txt', mode='r', encoding='utf-16-le')
file_new = open('new.txt', mode='w', encoding='utf-8')
text = file_old.read()
file_new.write(text.encode('utf-8'))
http://docs.python.org/release/2.3/lib/node126.html (--utf_16_le UTF-16LE)
不工作。无法理解“TypeError: must be str, not bytes”错误。
蟒蛇3
【问题讨论】: