【发布时间】:2017-05-31 18:43:35
【问题描述】:
我正在使用 python 2.7,我正在尝试使用某种编码编写一个文件(在我的“finalList”变量中,编码是:0xe9)
这就是我尝试使用“json”和“io”模块编写文件的方式
import json
import io
with io.open('my.json', 'w', encoding='utf8') as outfile:
json.dump(finalList, outfile)
【问题讨论】:
-
我打赌你正在运行 python 2。
-
是的,我刚刚更新了帖子说我使用的是 2.7
-
刚刚为您找到了一些答案。
-
你根本没有使用
codecs。
标签: python json python-2.7 encode