Liang Zou's Tech Blog
Thank you for visiting!
8/23/2007
两个unicode strings相加竟然会出错
a = '每' [a' = unichr(255) then a'.encode('utf-8') == '每']
b = u'completed'
c = '%s %s' % (a, b) 或 c = a + b竟然会出现错误 UnicodeDecodeError,不知道是什么原因
原来python 试图把str转化为unicode, 这时候str 为 '每',是不可能用ascii来表示的,所以出现decode error.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment