Metamorphosis
RSS feed

Python如何输出包含在对象中的中文字符?

def zhprint(obj):
import re
print re.sub(r"\\u([a-f0-9]{4})", lambda mg: unichr(int(mg.group(1), 16)), obj.__repr__())



yeah it's a hack but it works (for most cases)...
原发布于 https://www.zhihu.com/question/20413029/answer/15064222


published 10 Aug 2012
blog comments powered by Disqus

Existentials

  • github
  • flickr
  • twitter
  • facebook
  • linkedin

Blogroll

  • wonderfulmore
  • 北京人在悉尼
  • sukie赵
  • cjPanda
  • btsb
  • vivian
  • cityyoho
  • maple
  • tulip
  • 坦克梁
  • stone
  • pavements
  • 问号鱼
  • Schlaraffenland
  • 東亞毒液學研究所
  • 草木贲华
  • 三楼的卡西欧计算器
  • 追忆吹水年华
  • bad habits die hard
  • 多说无益
  • 一天世界
  • 得果德语