Re: 答复: 关于打印乱码问题,请 教

"大郎" <[email protected]> Sun, 20 Jan 2008 18:59:47 +0800
Newsgroups gmane.comp.python.chinese
Message-ID <[email protected]>
据我的经验是当前文件使用utf-8编码,不会出现问题,不知你是在命令行下还是web下?

On 1/20/08, gary.jsz <[email protected]> wrote:
>
>  有什么方法可以让他直接打印中文嘛?
>
>  ------------------------------
>  *发件人:* Handle.Huang
> *发送时间:* 2008-01-20 16:52:10
> *收件人:* [email protected]
> *抄送:*
> *主题:* [python-chinese] 答复: 关于打印乱码问题,请教
>
>
> Python内部都是按照Uncode来处理的。
>
>
>
> *发件人:* [email protected] [mailto:
> [email protected]] *代表 *gary.jsz
> *发送时间:* 2008年1月20日 16:36
> *收件人:* [email protected]
> *主题:* [python-chinese] 关于打印乱码问题,请教
>
>
>
> 代码如下:
>
> #-*-coding=gb2312-*-
>
>
>
> d1 = {1:'中国人', 2:'中国龙',3:'龙芯CPU', 4:'巨蟒'}
> print d1
> for i in d1.keys():
>     print i, '\t' ,d1[i]
> y = len(d1)
> print y
>
>
>
>
>
> 为何只答应d1的时候是下面的这些字符,而佚代后确打印正常,请问为什么?
>
> 结果如下:
>
> {1: '\xd6\xd0\xb9\xfa\xc8\xcb', 2: '\xd6\xd0\xb9\xfa\xc1\xfa', 3:
> '\xc1\xfa\xd0\xbeCPU', 4: '\xbe\xde\xf2\xfe'}
> 1  中国人
> 2  中国龙
> 3  龙芯CPU
> 4  巨蟒
> 4
>
> _______________________________________________
> python-chinese
> Post: send [email protected]
> Subscribe: send subscribe to [email protected]
> Unsubscribe: send unsubscribe to  [email protected]
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
http://del.icio.us/iexper
http://twitter.com/qichangxing
http://webpy.org
http://blog.hi0791.com (build with web.py)
http://www.baicai.com 百才招聘
Gtalk: iexper(at)gmail.com

_______________________________________________
python-chinese
Post: send [email protected]
Subscribe: send subscribe to [email protected]
Unsubscribe: send unsubscribe to  [email protected]
Detail Info: http://python.cn/mailman/listinfo/python-chinese