我使用以下代码使用python(3.4)美化一个js文件(带有jsbeautifier模块)
import jsbeautifier
def write_file(output, fn):
file = open(fn, "w")
file.write(output)
file.close()
def beautify_file():
res = jsbeautifier.beautify_file("myfile.js")
write_file(res, "myfile-exp.js")
print("beautify_file done")
def main():
beautify_file()
print("done")
pass
if __name__ == '__main__':
main()
该文件包含以下内容:
function MyFunc(){
return {Language:"Мова",Theme:"ТÑма"};
}
当我运行 python 代码时,我收到以下错误:
'charmap' codec can't decode byte 0x90 in position 43: character maps to <undefined>
有人可以指导我如何使用美化器处理 unicode/utf-8 字符集吗?
谢谢