我想编写一个python脚本,将文件编码从cp949转换为utf8。该文件最初在cp949中编码。我的脚本如下:
cpstr = open('terms.rtf').read()
utfstr = cpstr.decode('cp949').encode('utf-8')
tmp = open('terms_utf.rtf', 'w')
tmp.write(utfstr)
tmp.close()
Run Code Online (Sandbox Code Playgroud)
但这并没有改变我的编码。