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

"Handle.Huang" <[email protected]> Sun, 20 Jan 2008 16:51:51 +0800
Newsgroups gmane.comp.python.chinese
Message-ID <[email protected]>
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