pprint似乎
repr默认使用,您可以通过重写来解决此问题
PrettyPrinter.format:
# coding=utf8import pprintclass MyPrettyPrinter(pprint.PrettyPrinter): def format(self, object, context, maxlevels, level): if isinstance(object, unipre): return (object.enpre('utf8'), True, False) return pprint.PrettyPrinter.format(self, object, context, maxlevels, level)d = {'foo': u'işüğçö'}pprint.pprint(d) # {'foo': u'iu015fxfcu011fxe7xf6'}MyPrettyPrinter().pprint(d) # {'foo': işüğçö}


