> *最后的输出为:*
raw_input读入的字符如何转化为unicode格式的呢?
我试过unicode(temp)然后再调用uniform函数也是不行的。
temp=u'Abhello,world!中国safds'
print uniform(temp)
这个运行提示错误:
Traceback (most recent call last):
File "trans2.py", line 34, in ?
print uniform(temp)
UnicodeError: ASCII encoding error: ordinal not in range(128)
为什么呢?
我的 $LANG为“en_US.”
On 3月25日, 下午1时45分, anny raul <annyr...@gmail.com> wrote:
> >>> s = raw_input("input:")
> input:汉字
> >>> s
> '\xba\xba\xd7\xd6'
> >>> b = unicode(s.decode('gbk'))
> >>> b
>
> u'\u6c49\u5b57'
>
> 跟你系统环境有关,偶是win这么尝试就ok了
>
> 2009/3/25 SunShine <jingwei...@gmail.com>
>
> > raw_input读入的字符如何转化为unicode格式的呢?
> > 我试过unicode(temp)然后再调用uniform函数也是不行的。
>
> --
> anny raul <annyr...@gmail.com>http://annyraul.blogspot.com