赞
踩
1 、将Unicode转换成普通的Python字符串:“编码(encode)”
unicodestring = u"Hello world"
utf8string = unicodestring.encode("utf-8")
asciistring = unicodestring.encode("ascii")
isostring = unicodestring.encode("ISO-8859-1")
utf16string = unicodestring.encode("utf-16")
2、将普通的Python字符串转换成Unicode: “解码(decode)”
plainstring1 = unicode(utf8string, "utf-8")
plainstring2 = unicode(asciistring, "ascii")
plainstring3 = unicode(isostring, "ISO-8859-1")
plainstring4 = unicode(utf16string, "utf-16")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。