Skip to content

Instantly share code, notes, and snippets.

@HQMIS
Created January 11, 2013 12:27
Show Gist options
  • Select an option

  • Save HQMIS/4510315 to your computer and use it in GitHub Desktop.

Select an option

Save HQMIS/4510315 to your computer and use it in GitHub Desktop.
>>> a = "你好"
>>> a
'\xe4\xbd\xa0\xe5\xa5\xbd'
>>> b = u"你好"
>>> b
u'\u4f60\u597d'
>>> print a
你好
>>> print b
你好
>>> c = u"\xe4\xbd\xa0\xe5\xa5\xbd"
我要对c进行什么样的转换才能输出汉字“你好“呢
@HQMIS

HQMIS commented Jan 11, 2013

Copy link
Copy Markdown
Author

灯会回去试验

ucname = urllib.unquote(str(u))
u2=ucname.decode("utf-8")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment