【问题标题】:Write UTF-8 strings to file with pprint使用 pprint 将 UTF-8 字符串写入文件
【发布时间】:2015-02-23 09:44:21
【问题描述】:

我想将带有 UTF-8 字符串的字典写入文件。我看到another 线程关于使用 pprint 打印 utf-8 字符串,并尝试像这样修改那里看到的代码

MyPrettyPrinter().pprint(dict, stream=f)

但它不起作用。我对 python 中的类没有经验,所以我不知道在 pprint 库中重新定义什么。

【问题讨论】:

  • 对不起,我错过了你的链接,我看不清楚,或者这里的超链接不够亮

标签: python file utf-8 stream pprint


【解决方案1】:

应该是:

MyPrettyPrinter(stream=f).pprint(d)

【讨论】:

    猜你喜欢
    • 2011-09-06
    • 2011-08-31
    • 1970-01-01
    • 2014-04-06
    • 2023-03-27
    • 2016-05-03
    • 2011-06-16
    • 1970-01-01
    相关资源
    最近更新 更多