1234567891011121314 |
- # -*- coding: utf-8 -*-
- #!/usr/bin/env python
- import pprint
- class UnicodePrettyPrinter(pprint.PrettyPrinter):
- """
- 可以方便地打印出unicode
- """
- def format(self, object, context, maxlevels, level):
- ret = pprint.PrettyPrinter.format(self, object, context, maxlevels, level)
- if isinstance(object, unicode):
- ret = (object.encode('utf-8'), ret[1], ret[2])
- return ret
|