2004年03月10日 星期三 09:25
我在我的Win2K上运行如下的代码没有问题。
# -*- coding: cp936 -*-
import locale
encoding = locale.getdefaultlocale()[1]
s1 =
unicode('中华人民共和国',
encoding)
s2 =
'中华人民共和国'
print s1.encode(encoding), s2
print len(s1), len(s2) # 输出:7 14
代码是从楼上某位仁兄提供的链接上得到的。
但是,我如果在实验室的Mandrake
linux上运行这一段程序,就得到如下的错误:
SyntaxError: 'unknown encoding: cp936'
是不是因为这个mandrake上没有中文系统?
我不是超级管理员,我要让超级用户安装什么东西呢?
Mandrake上的locale如下:
>>> locale.getdefaultlocale()
['en_US', 'ISO8859-1']
__________________________________
Do you Yahoo!?
Yahoo! Search - Find what youre looking for faster
http://search.yahoo.com
2004年03月10日 星期三 09:28
为什么不能加入Zope列表?在确认时收到 发件人 : <postmaster at exoweb.net> 发送 : 2004年3月10日 9:02:10 收件人 : whoonline at msn.com 主题 : Delivery Status Notification (Failure) This is an automatically generated Delivery Status Notification. Delivery to the following recipients failed. zope-chinese-request at exoweb.net 这是怎么回事啊? _________________________________________________________________ 与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
2004年03月10日 星期三 09:38
Hello Anthony,
bad code mail!!!!
what happen?
=== [ 9:25 ; 04-03-10 ] you wrote:
AL> 我在我的Win2K上运行如下的代码没有问题。
AL> # -*- coding: cp936 -*-
AL> import locale
AL> encoding = locale.getdefaultlocale()[1]
AL> s1 =
AL> unicode('中华人民共和国',
AL> encoding)
AL> s2 =
AL> '中华人民共和国'
AL> print s1.encode(encoding), s2
AL> print len(s1), len(s2) # 输出:7 14
AL> 代码是从楼上某位仁兄提供的链接上得到的。
AL> 但是,我如果在实验室的Mandrake
AL> linux上运行这一段程序,就得到如下的错误:
AL> SyntaxError: 'unknown encoding: cp936'
AL> 是不是因为这个mandrake上没有中文系统?
AL> 我不是超级管理员,我要让超级用户安装什么东西呢?
AL> Mandrake上的locale如下:
>>>> locale.getdefaultlocale()
AL> ['en_US', 'ISO8859-1']
AL> __________________________________
AL> Do you Yahoo!?
AL> Yahoo! Search - Find what youre looking for faster
AL> http://search.yahoo.com
=== === === === === === === === === ===
--
Best regards,
Zoom.Quiet
/=======================================\
]Time is unimportant, only life important![
\=======================================/
2004年03月10日 星期三 10:52
1) I converted your email--it looks like
it had an ascii encoding, not a gb encoding.
2) On your system, does locale.getdefaultlocale()[1]
return ISO8859-1 or cp936, after
'# -*- coding: cp936 -*-'?
You can simply use unicode('中华人民共和国','gbk')
(cp936 is more of a Microsoft name; 'gbk' is
more common elsewhere)
3) You have to install CJKCodecs from
http://cjkpython.i18n.org/ before the unicode()
and encode() functions work with gbk/cp936.
---------------------------------
我在我的Win2K上运行如下的代码没有问题。
# -*- coding: cp936 -*-
import locale
encoding = locale.getdefaultlocale()[1]
s1 =
unicode('中华人民共和国',
encoding)
s2 =
'中华人民共和国'
print s1.encode(encoding), s2
print len(s1), len(s2) # 输出:7 14
代码是从楼上某位仁兄提供的链接上得到的。
但是,我如果在实验室的Mandrake
linux上运行这一段程序,就得到如下的错误:
SyntaxError: 'unknown encoding: cp936'
是不是因为这个mandrake上没有中文系统?
我不是超级管理员,我要让超级用户安装什么东西呢?
Mandrake上的locale如下:
>>> locale.getdefaultlocale()
['en_US', 'ISO8859-1']
Zeuux © 2025
京ICP备05028076号