Python论坛  - 讨论区

标题:[python-chinese] Re: python-chinese Digest, Vol 3, Issue 61

2004年03月31日 星期三 11:25

zhangdm zhangdm at intelware.com.cn
Wed Mar 31 11:25:57 HKT 2004

怎么不给我发邮件了?





> Message: 2
> Date: Tue, 16 Mar 2004 23:37:37 -0800 (PST)
> From: Anthony Liu <antonyliu2002 at yahoo.com>
> Subject: Re: Re[4]: [python-chinese] cjkcodecs on mandrake, a problem
> To: python-chinese at lists.python.cn
> Message-ID: <20040317073737.61304.qmail at web13003.mail.yahoo.com>
> Content-Type: text/plain; charset=us-ascii
> 
> I also wanna know that, but, tell you what, I am not
> the super user, so I don't know if it is installed
> correctly.
> 
> But if I can install it under my own home directory
> and let python know it, then it's also fine with me,
> but I don't know if this is possible, and how do I let
> python know where cjkcodecs is?
> 
> Actually, I guess it is installed OK, because when I
> encode strings in English using gbk, it works fine. 
> It just does not work for Chinese.
> 
> Any idea?
> 
> --- Who Bruce <whoonline at msn.com> wrote:
> > I have no ideas now, the last suggestion: is your
> > codec module for Chinese 
> > gb2312 installed correctly?
> > 
> > >From: Anthony Liu <antonyliu2002 at yahoo.com>
> > >Reply-To: python-chinese at lists.python.cn
> > >To: pycn <python-chinese at lists.python.cn>
> > >Subject: Re: Re[4]: [python-chinese] cjkcodecs on
> > mandrake, a problem
> > >Date: Tue, 16 Mar 2004 23:28:27 -0800 (PST)
> > >
> > >I've added
> > >
> > >export LANG=zh_CN.GB2312
> > >
> > >in both .bash_profile and .bashrc
> > >
> > >Now, if I issue 'locale', I get:
> > >
> > >LANG=zh_CN.GB2312
> > >LC_CTYPE=en_US
> > >LC_NUMERIC=en_US
> > >LC_TIME=en_US
> > >LC_COLLATE=en_US
> > >LC_MONETARY=en_US
> > >LC_MESSAGES=en_US
> > >LC_PAPER=en_US
> > >LC_NAME=en_US
> > >LC_ADDRESS=en_US
> > >LC_TELEPHONE=en_US
> > >LC_MEASUREMENT=en_US
> > >LC_IDENTIFICATION=en_US
> > >LC_ALL=
> > >
> > >Notice that LANG=zh_CN.GB2312, which seems to be
> > what
> > >I want, but still when I run the following script:
> > >
> > >s = '蟒蛇' # s is a string in Chinese
> > >s = unicode(s, 'gb2312')
> > >print s
> > >
> > >I still get the same error message:
> > >
> > >UnicodeEncodeError: 'latin-1' codec can't encode
> > >characters in position 0-1: ordinal not in
> > range(256).
> > >
> > >What should I do?  Thank you!
> > >
> > >
> > >--- "Zoom.Quiet" <zoomq at infopro.cn> wrote:
> > > > Hello Anthony,
> > > >
> > > > if define
> > > > # -*- coding: utf-8 -*-
> > > >
> > > > u editor must can import unicode code;
> > > > not like the '蟒蛇' ASII  utf-8 encode
> > > > codes!!!
> > > >
> > > >
> > > > === [ 11:18 ; 04-03-17 ] you wrote:
> > > >
> > > > AL> "Zoom.Quiet" <zoomq at itcase.com>,
> > > > zoomq at infopro.cn,
> > > > AL> INVALID_ADDRESS at .SYNTAX-ERROR.
> > > >
> > > > AL> does not work.  look at this:
> > > >
> > > > AL> # -*- coding: utf-8 -*-
> > > >
> > > > AL> a = '蟒蛇'
> > > > AL> b = 'abc'
> > > > AL> a = unicode(a, 'utf-8')
> > > > AL> print a
> > > >
> > > > AL> Traceback (most recent call last):
> > > > AL>   File "snake.py", line 8, in ?
> > > > AL>     a = unicode(a, 'utf-8')
> > > > AL> UnicodeDecodeError: 'utf8' codec can't
> > decode
> > > > bytes in
> > > > AL> position 0-3: invalid data
> > > >
> > > > AL> --- "Zoom.Quiet" <zoomq at infopro.cn> wrote:
> > > > >> Hello Anthony,
> > > > >>
> > > > >> after Python 2.3.x
> > > > >> u can insert line::
> > > > >> """
> > > > >> # -*- coding: utf-8 -*-
> > > > >> """
> > > > >> at script 1st
> > > > >>
> > > > >> to make Python know what encode u will write
> > > > >>
> > > > >> === [ 10:44 ; 04-03-17 ] you wrote:
> > > > >>
> > > > >> AL> Can I just call
> > > > locale.setlocale(locale.LC_ALL,
> > > > >> AL> 'zh_CN') in my python script?
> > > > >>
> > > > >> AL> --- Who Bruce <whoonline at msn.com> wrote:
> > > > >> >> IIRC, ~/.lang
> > > > >> >> edit it
> > > > >> >> set environment LC_LANG and LC_LOCALE and
> > > > other
> > > > >> >> essential evironment.
> > > > >> >> I forget the details,just google it.
> > > > >> >> good luck
> > > > >> >>
> > > > >> >> >From: Anthony Liu
> > <antonyliu2002 at yahoo.com>
> > > > >> >> >Reply-To: python-chinese at lists.python.cn
> > > > >> >> >To: python-chinese at lists.python.cn
> > > > >> >> >Subject: Re: [python-chinese] cjkcodecs
> > on
> > > > >> >> mandrake, a problem
> > > > >> >> >Date: Tue, 16 Mar 2004 18:37:39 -0800
> > (PST)
> > > > >> >> >
> > > > >> >> >Thanks, Bruce.
> > > > >> >> >
> > > > >> >> >Where is the .lang file?  Should I create
> > it
> > > > >> from
> > > > >> >> >scratch?
> > > > >> >> >
> > > > >> >> >And what lines should it contain?
> > > > >> >> >
> > > > >> >> >The env command of the Mandrake shows:
> > > > >> >> >
> > > > >> >> >LANG=en_US
> > > > >> >> >
> > > > >> >> >
> > > > >> >> >--- Who Bruce <whoonline at msn.com> wrote:
> > > > >> >> > > I think you can change your Mandrake's
> > > > local
> > > > >> and
> > > > >> >> > > language setting to
> > > > >> >> > > Chinese. IIRC, change .lang file
> > > > >> >> > >
> > > > >> >> > >
> > > > >> >> > > >From: "Zoom.Quiet" <zoomq at infopro.cn>
> > > > >> >> > > >Reply-To: "Zoom.Quiet"
> > > > <zoomq at itcase.com>,
> > > > >> >> > > zoomq at infopro.cn,
> > > > >> >> > > ,python-chinese at lists.python.cn
> > > > >> >> > > >To: python-chinese at lists.python.cn
> > > > >> >> > > >Subject: Re: [python-chinese]
> > cjkcodecs
> > > > on
> > > > >> >> > > mandrake, a problem
> > > > >> >> > > >Date: Wed, 17 Mar 2004 10:21:21 +0800
> > > > >> >> > > >
> > > > >> >> > > >Hello Anthony,
> > > > >> >> > > >
> > > > >> >> > > >"'latin-1' codec can't encode" is the
> > > > key!
> > > > >> >> > > >u say::
> > > > >> >> > > >s = "蟒蛇"  # 2 Chinese
> > > > >> characters
> > > > >> AL> for
> > > > >> >> > > >
> > > > >> >> > > >??
> > > > >> >> > > >but we can see it as chinese!
> > > > >> >> > > >so so means in u sys default location
> > is
> > > > >> >> latin-1!!
> > > > >> >> > > >
> > > > >> >> > > >anything encode as latin-1 ??
> > > > >> >> > > >
> > > > >> >> > > >so so poor Mandrake.....
> > > > >> >> > > >
> > > > >> >> > > >
> > > > >> >> > > >
> > > > >> >> > > >=== [ 10:12 ; 04-03-17 ] you wrote:
> > > > >> >> > > >
> > > > >> >> > > >AL> The superuser of the Mandrake
> > system
> > > > in
> > > > >> my
> > > > >> >> lab
> > > > >> >> > > >AL> installed cjkcodecs for python.
> > > > >> >> > > >
> > > > >> >> > > >AL> But there is a problem.
> > > > >> >> > > >
> > > > >> >> > > >AL> I can encode english alphabets
> > like
> > > > 'a',
> > > > >> >> 'b',
> > > > >> >> > > 'c' or
> > > > >> >> > > >AL> 'abc' like so:
> > > > >> >> > > >
> > > > >> >> > > >AL> s = 'abc'
> > > > >> >> > > >AL> s = unicode(s, 'gbk')
> > > > >> >> > > >AL> print s # prints 'abc'
> > > > >> >> > > >
> > > > >> >> > > >AL> but when I tried to encode
> > Chinese
> > 
> === message truncated ===
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - More reliable, more storage, less spam
> http://mail.yahoo.com
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Wed, 17 Mar 2004 15:41:49 +0800
> From: "Qiangning Hong" <lucifer at tsinghua.org.cn>
> Subject: [python-chinese] protected attributes?
> To: <python-chinese at lists.python.cn>
> Message-ID:
> <900D4E3F1C745D478E67635030C8F11E0579DB at hlx-pdc.hailanxin.com>
> Content-Type: text/plain; charset="gb2312"
> 
> 从Python的Tutorial里知道了在class里定义private成员的方法是在其名字前加上
> 两个下划线。可是这样以后,连从该类继承的子类也不能访问这个成员。有什么办
> 法可以让某个成员对外界不可见但是对子类可见呢?
>  
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20040317/6d09f80e/attachment.htm
> 
> ------------------------------
> 
> Message: 4
> Date: Wed, 17 Mar 2004 15:51:26 +0800
> From: 刘鑫 <liux at gdcn.com>
> Subject: Re: [python-chinese] protected attributes?
> To: "python-chinese at lists.python.cn" <python-chinese at lists.python.cn>
> Message-ID: <0HUP00AR2MXLKW at db.gdcn.com>
> Content-Type: text/plain; charset="gb2312"
> 
> Qiangning Hong,您好! 
> 
>   实际上Python没有完备的封装与继承机制――以后相当一段时间内可能也无意增加。我们现在没有protected类型的成员可用。不过实际上private也是可访问的,只是我们不能直接搜索到它而已。只要你知道它的存在,应该是可以像普通成员一样直接使用。
> 
> ======== 2004-03-17 15:41:49 您在来信中写道: ========
> 
> 从Python的Tutorial里知道了在class里定义private成员的方法是在其名字前加上两个下划线。可是这样以后,连从该类继承的子类也不能访问这个成员。有什么办法可以让某个成员对外界不可见但是对子类可见呢?
> 
> 
> = = = = = = = = = = = = = = = = = = = = = = 
>         致
> 礼!
> 
>               刘鑫
>               liux at gdcn.com
>                  2004-03-17
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20040317/1f755252/attachment.html
> 
> ------------------------------
> 
> Message: 5
> Date: Wed, 17 Mar 2004 15:55:56 +0800
> From: "Zoom.Quiet" <zoomq at infopro.cn>
> Subject: Re[6]: [python-chinese] cjkcodecs on mandrake, a problem
> To: python-chinese at lists.python.cn
> Message-ID: <1896637808.20040317155556 at itcase.com,zoomq at infopro.cn>
> Content-Type: text/plain; charset=gb2312
> 
> Hello Anthony,
> 
> u can not run as root??
> 
> this this key infomation!
> 
> but u can try 
> #!/u/instll/where/CJKPython/python
> 
> to make sure right version Python to run!
> 
> and
> http://www.linuxforum.net/forum/gshowflat.php?Cat=&Board;=python&Number;=427317&page;=0&view;=collapsed&sb;=5&o;=all&fpart;=
> 
> is some detail of gbutf encode....
> 
> good luck!
> 
> === [ 15:37 ; 04-03-17 ] you wrote:
> 
> AL> I also wanna know that, but, tell you what, I am not
> AL> the super user, so I don't know if it is installed
> AL> correctly.
> 
> AL> But if I can install it under my own home directory
> AL> and let python know it, then it's also fine with me,
> AL> but I don't know if this is possible, and how do I let
> AL> python know where cjkcodecs is?
> 
> AL> Actually, I guess it is installed OK, because when I
> AL> encode strings in English using gbk, it works fine. 
> AL> It just does not work for Chinese.
> 
> AL> Any idea?
> 
> AL> --- Who Bruce <whoonline at msn.com> wrote:
> >> I have no ideas now, the last suggestion: is your
> >> codec module for Chinese 
> >> gb2312 installed correctly?
> >> 
> >> >From: Anthony Liu <antonyliu2002 at yahoo.com>
> >> >Reply-To: python-chinese at lists.python.cn
> >> >To: pycn <python-chinese at lists.python.cn>
> >> >Subject: Re: Re[4]: [python-chinese] cjkcodecs on
> >> mandrake, a problem
> >> >Date: Tue, 16 Mar 2004 23:28:27 -0800 (PST)
> >> >
> >> >I've added
> >> >
> >> >export LANG=zh_CN.GB2312
> >> >
> >> >in both .bash_profile and .bashrc
> >> >
> >> >Now, if I issue 'locale', I get:
> >> >
> >> >LANG=zh_CN.GB2312
> >> >LC_CTYPE=en_US
> >> >LC_NUMERIC=en_US
> >> >LC_TIME=en_US
> >> >LC_COLLATE=en_US
> >> >LC_MONETARY=en_US
> >> >LC_MESSAGES=en_US
> >> >LC_PAPER=en_US
> >> >LC_NAME=en_US
> >> >LC_ADDRESS=en_US
> >> >LC_TELEPHONE=en_US
> >> >LC_MEASUREMENT=en_US
> >> >LC_IDENTIFICATION=en_US
> >> >LC_ALL=
> >> >
> >> >Notice that LANG=zh_CN.GB2312, which seems to be
> >> what
> >> >I want, but still when I run the following script:
> >> >
> >> >s = '蟒蛇' # s is a string in Chinese
> >> >s = unicode(s, 'gb2312')
> >> >print s
> >> >
> >> >I still get the same error message:
> >> >
> >> >UnicodeEncodeError: 'latin-1' codec can't encode
> >> >characters in position 0-1: ordinal not in
> >> range(256).
> >> >
> >> >What should I do?  Thank you!
> >> >
> >> >
> >> >--- "Zoom.Quiet" <zoomq at infopro.cn> wrote:
> >> > > Hello Anthony,
> >> > >
> >> > > if define
> >> > > # -*- coding: utf-8 -*-
> >> > >
> >> > > u editor must can import unicode code;
> >> > > not like the '蟒蛇' ASII  utf-8 encode
> >> > > codes!!!
> >> > >
> >> > >
> >> > > === [ 11:18 ; 04-03-17 ] you wrote:
> >> > >
> >> > > AL> "Zoom.Quiet" <zoomq at itcase.com>,
> >> > > zoomq at infopro.cn,
> >> > > AL> INVALID_ADDRESS at .SYNTAX-ERROR.
> >> > >
> >> > > AL> does not work.  look at this:
> >> > >
> >> > > AL> # -*- coding: utf-8 -*-
> >> > >
> >> > > AL> a = '蟒蛇'
> >> > > AL> b = 'abc'
> >> > > AL> a = unicode(a, 'utf-8')
> >> > > AL> print a
> >> > >
> >> > > AL> Traceback (most recent call last):
> >> > > AL>   File "snake.py", line 8, in ?
> >> > > AL>     a = unicode(a, 'utf-8')
> >> > > AL> UnicodeDecodeError: 'utf8' codec can't
> >> decode
> >> > > bytes in
> >> > > AL> position 0-3: invalid data
> >> > >
> >> > > AL> --- "Zoom.Quiet" <zoomq at infopro.cn> wrote:
> >> > > >> Hello Anthony,
> >> > > >>
> >> > > >> after Python 2.3.x
> >> > > >> u can insert line::
> >> > > >> """
> >> > > >> # -*- coding: utf-8 -*-
> >> > > >> """
> >> > > >> at script 1st
> >> > > >>
> >> > > >> to make Python know what encode u will write
> >> > > >>
> >> > > >> === [ 10:44 ; 04-03-17 ] you wrote:
> >> > > >>
> >> > > >> AL> Can I just call
> >> > > locale.setlocale(locale.LC_ALL,
> >> > > >> AL> 'zh_CN') in my python script?
> >> > > >>
> >> > > >> AL> --- Who Bruce <whoonline at msn.com> wrote:
> >> > > >> >> IIRC, ~/.lang
> >> > > >> >> edit it
> >> > > >> >> set environment LC_LANG and LC_LOCALE and
> >> > > other
> >> > > >> >> essential evironment.
> >> > > >> >> I forget the details,just google it.
> >> > > >> >> good luck
> >> > > >> >>
> >> > > >> >> >From: Anthony Liu
> >> <antonyliu2002 at yahoo.com>
> >> > > >> >> >Reply-To: python-chinese at lists.python.cn
> >> > > >> >> >To: python-chinese at lists.python.cn
> >> > > >> >> >Subject: Re: [python-chinese] cjkcodecs
> >> on
> >> > > >> >> mandrake, a problem
> >> > > >> >> >Date: Tue, 16 Mar 2004 18:37:39 -0800
> >> (PST)
> >> > > >> >> >
> >> > > >> >> >Thanks, Bruce.
> >> > > >> >> >
> >> > > >> >> >Where is the .lang file?  Should I create
> >> it
> >> > > >> from
> >> > > >> >> >scratch?
> >> > > >> >> >
> >> > > >> >> >And what lines should it contain?
> >> > > >> >> >
> >> > > >> >> >The env command of the Mandrake shows:
> >> > > >> >> >
> >> > > >> >> >LANG=en_US
> >> > > >> >> >
> >> > > >> >> >
> >> > > >> >> >--- Who Bruce <whoonline at msn.com> wrote:
> >> > > >> >> > > I think you can change your Mandrake's
> >> > > local
> >> > > >> and
> >> > > >> >> > > language setting to
> >> > > >> >> > > Chinese. IIRC, change .lang file
> >> > > >> >> > >
> >> > > >> >> > >
> >> > > >> >> > > >From: "Zoom.Quiet" <zoomq at infopro.cn>
> >> > > >> >> > > >Reply-To: "Zoom.Quiet"
> >> > > <zoomq at itcase.com>,
> >> > > >> >> > > zoomq at infopro.cn,
> >> > > >> >> > > ,python-chinese at lists.python.cn
> >> > > >> >> > > >To: python-chinese at lists.python.cn
> >> > > >> >> > > >Subject: Re: [python-chinese]
> >> cjkcodecs
> >> > > on
> >> > > >> >> > > mandrake, a problem
> >> > > >> >> > > >Date: Wed, 17 Mar 2004 10:21:21 +0800
> >> > > >> >> > > >
> >> > > >> >> > > >Hello Anthony,
> >> > > >> >> > > >
> >> > > >> >> > > >"'latin-1' codec can't encode" is the
> >> > > key!
> >> > > >> >> > > >u say::
> >> > > >> >> > > >s = "蟒蛇"  # 2 Chinese
> >> > > >> characters
> >> > > >> AL> for
> >> > > >> >> > > >
> >> > > >> >> > > >??
> >> > > >> >> > > >but we can see it as chinese!
> >> > > >> >> > > >so so means in u sys default location
> >> is
> >> > > >> >> latin-1!!
> >> > > >> >> > > >
> >> > > >> >> > > >anything encode as latin-1 ??
> >> > > >> >> > > >
> >> > > >> >> > > >so so poor Mandrake.....
> >> > > >> >> > > >
> >> > > >> >> > > >
> >> > > >> >> > > >
> >> > > >> >> > > >=== [ 10:12 ; 04-03-17 ] you wrote:
> >> > > >> >> > > >
> >> > > >> >> > > >AL> The superuser of the Mandrake
> >> system
> >> > > in
> >> > > >> my
> >> > > >> >> lab
> >> > > >> >> > > >AL> installed cjkcodecs for python.
> >> > > >> >> > > >
> >> > > >> >> > > >AL> But there is a problem.
> >> > > >> >> > > >
> >> > > >> >> > > >AL> I can encode english alphabets
> >> like
> >> > > 'a',
> >> > > >> >> 'b',
> >> > > >> >> > > 'c' or
> >> > > >> >> > > >AL> 'abc' like so:
> >> > > >> >> > > >
> >> > > >> >> > > >AL> s = 'abc'
> >> > > >> >> > > >AL> s = unicode(s, 'gbk')
> >> > > >> >> > > >AL> print s # prints 'abc'
> >> > > >> >> > > >
> >> > > >> >> > > >AL> but when I tried to encode
> >> Chinese
> >> 
> AL> === message truncated ===
> 
> 
> AL> __________________________________
> AL> Do you Yahoo!?
> AL> Yahoo! Mail - More reliable, more storage, less spam
> AL> http://mail.yahoo.com
> 
> === === === === === === === === === === 
> 
> -- 
> Best regards,
>  Zoom.Quiet                            
> 
>  /=======================================\
> ]Time is unimportant, only life important![
>  \=======================================/
> 
> 
> 
> ------------------------------
> 
> Message: 6
> Date: Wed, 17 Mar 2004 15:57:43 +0800
> From: "Zoom.Quiet" <zoomq at infopro.cn>
> Subject: Re: [python-chinese] protected attributes?
> To: python-chinese at lists.python.cn
> Message-ID: <28438991.20040317155743 at itcase.com,zoomq at infopro.cn>
> Content-Type: text/plain; charset=gb2312
> 
> Hello Qiangning,
> 
> 有必要嘛?
> 真的如此,不如直接移动入子类,成为子类的private;
> 
> 
> === [ 15:41 ; 04-03-17 ] you wrote:
> 
> QH> 从Python的Tutorial里知道了在class里定义private成员的方法是在其名字前加上
> QH> 两个下划线。可是这样以后,连从该类继承的子类也不能访问这个成员。有什么办
> QH> 法可以让某个成员对外界不可见但是对子类可见呢?
>  
> 
> === === === === === === === === === === 
> 
> -- 
> Best regards,
>  Zoom.Quiet                            
> 
>  /=======================================\
> ]Time is unimportant, only life important![
>  \=======================================/
> 
> 
> 
> ------------------------------
> 
> Message: 7
> Date: Wed, 17 Mar 2004 16:00:52 +0800
> From: zhao <bear_sh at eastday.com>
> Subject: Re: [python-chinese] protected attributes?
> To: "python-chinese at lists.python.cn" <python-chinese at lists.python.cn>
> Message-ID: <0HUP004FUNNMOB at mail5.eastday.com>
> Content-Type: text/plain; charset="gb2312"
> 
> Skipped content of type multipart/alternative-------------- next part --------------
> A non-text attachment was scrubbed...
> Name: fox.gif
> Type: image/gif
> Size: 9519 bytes
> Desc: not available
> Url : http://lists.exoweb.net/pipermail/python-chinese/attachments/20040317/c55f039a/fox.gif
> 
> ------------------------------
> 
> _______________________________________________
> python-chinese mailing list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> 
> 
> End of python-chinese Digest, Vol 3, Issue 61
> *********************************************
> 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号