Python论坛  - 讨论区

标题:[python-chinese] ÄúºÃÎÒÒѾ­ÊÕµ½ÄúµÄÓʼþ

2004年03月17日 星期三 10:44

zhangdm at intelware.com.cn zhangdm at intelware.com.cn
Wed Mar 17 10:44:02 HKT 2004

ÄúºÃÎÒÒѾ­ÊÕµ½ÄúµÄÓʼþ£¬ÎÒµÄÓÊÏäÏÖÔÚÒѾ­¸ÄΪ£º
zhangdm at iwgroup.com.cn
ÒÔºóÄúÐèÒªÓʼþÁªÏµÎÒÇëEmailÖÁÎÒµÄÐÂÓÊÏ䣬лл£¡

                                       ÕŵÀÃ÷


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

2004年03月17日 星期三 10:48

Who Bruce whoonline at msn.com
Wed Mar 17 10:48:15 HKT 2004

eviroment will effect the whole Mandrake system, if you just use locale in 
you Python script,it just influence your script itself.


>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:44:32 -0800 (PST)
>
>Can I just call locale.setlocale(locale.LC_ALL,
>'zh_CN') in my python script?
>
>--- 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
>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 strings,
> > I
> > > > have a
> > > > >AL> problem.
> > > > >
> > > > >AL> For example, to run the following script:
> > > > >
> > > > >AL> s = "蟒蛇"  # 2 Chinese
>characters
> > >for
> > > > >AL> python
> > > > >AL> s = unicode(s, 'gbk')
> > > > >AL> print s
> > > > >
> > > > >AL> I get the following error message.
> > > > >
> > > > >AL> [antony at ancho tmp]$ python snake.py
> > > > >AL> Traceback (most recent call last):
> > > > >AL>   File "snake.py", line 6, in ?
> > > > >AL>     print a
> > > > >AL> UnicodeEncodeError: 'latin-1' codec can't
> > > > encode
> > > > >AL> characters in position 0-1: ordinal not in
> > > > range(256)
> > > > >AL> [antony at ancho tmp]$
> > > > >
> > > > >AL> What is the problem please?
> > > > >
> > > > >
> > > > >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![
> > > > >  \=======================================/
> > > > >
> > > > >_______________________________________________
> > > > >python-chinese list
> > > > >python-chinese at lists.python.cn
> > > >
> > >http://python.cn/mailman/listinfo/python-chinese
> > > >
> > > >
> >
> >_________________________________________________________________
> > > > 免费下载 MSN Explorer:
> > > > http://explorer.msn.com/lccn
> > > >
> > > > _______________________________________________
> > > > python-chinese list
> > > > python-chinese at lists.python.cn
> > > > http://python.cn/mailman/listinfo/python-chinese
> > >
> > >
> > >__________________________________
> > >Do you Yahoo!?
> > >Yahoo! Mail - More reliable, more storage, less
> > spam
> > >http://mail.yahoo.com
> > >_______________________________________________
> > >python-chinese list
> > >python-chinese at lists.python.cn
> > >http://python.cn/mailman/listinfo/python-chinese
> >
> >
>_________________________________________________________________
> > 免费下载 MSN Explorer:
> > http://explorer.msn.com/lccn
> >
> > _______________________________________________
> > python-chinese list
> > python-chinese at lists.python.cn
> > http://python.cn/mailman/listinfo/python-chinese
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Mail - More reliable, more storage, less spam
>http://mail.yahoo.com
>_______________________________________________
>python-chinese list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese

_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。  http://www.hotmail.com  



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

2004年03月17日 星期三 10:58

Anthony Liu antonyliu2002 at yahoo.com
Wed Mar 17 10:58:15 HKT 2004

Bruce, thanks.  But as long as it works for my python
script, it is good enough.  The thing is that I find
it does not even work.

When I call locale.setlocale(locale.LC_ALL, 'zh_CN'),
it complains:

  File "snake.py", line 4, in ?
    locale.setlocale(locale.LC_ALL, 'zh_CN')
  File "/usr/lib/python2.3/locale.py", line 381, in
setlocale
    return _setlocale(category, locale)
locale.Error: locale setting not supported


--- Who Bruce <whoonline at msn.com> wrote:
> eviroment will effect the whole Mandrake system, if
> you just use locale in 
> you Python script,it just influence your script
> itself.
> 
> 
> >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:44:32 -0800 (PST)
> >
> >Can I just call locale.setlocale(locale.LC_ALL,
> >'zh_CN') in my python script?
> >
> >--- 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
> >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
> strings,
> > > I
> > > > > have a
> > > > > >AL> problem.
> > > > > >
> > > > > >AL> For example, to run the following
> script:
> > > > > >
> > > > > >AL> s = "蟒蛇"  # 2 Chinese
> >characters
> > > >for
> > > > > >AL> python
> > > > > >AL> s = unicode(s, 'gbk')
> > > > > >AL> print s
> > > > > >
> > > > > >AL> I get the following error message.
> > > > > >
> > > > > >AL> [antony at ancho tmp]$ python snake.py
> > > > > >AL> Traceback (most recent call last):
> > > > > >AL>   File "snake.py", line 6, in ?
> > > > > >AL>     print a
> > > > > >AL> UnicodeEncodeError: 'latin-1' codec
> can't
> > > > > encode
> > > > > >AL> characters in position 0-1: ordinal not
> in
> > > > > range(256)
> > > > > >AL> [antony at ancho tmp]$
> > > > > >
> > > > > >AL> What is the problem please?
> > > > > >
> > > > > >
> > > > > >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![
> > > > > >  \=======================================/
> > > > > >
> > > > >
> >_______________________________________________
> > > > > >python-chinese list
> > > > > >python-chinese at lists.python.cn
> > > > >
> > >
> >http://python.cn/mailman/listinfo/python-chinese
> > > > >
> > > > >
> > >
> >
>
>_________________________________________________________________
> > > > > 免费下载 MSN
Explorer:
> > > > > http://explorer.msn.com/lccn
> > > > >
> > > > >
> _______________________________________________
> > > > > python-chinese list
> > > > > python-chinese at lists.python.cn
> > > > >
> http://python.cn/mailman/listinfo/python-chinese
> > > >
> > > >
> > > >__________________________________
> > > >Do you Yahoo!?
> > > >Yahoo! Mail - More reliable, more storage, less
> > > spam
> > > >http://mail.yahoo.com
> > > >_______________________________________________
> > > >python-chinese list
> > > >python-chinese at lists.python.cn
> > >
> >http://python.cn/mailman/listinfo/python-chinese
> > >
> > >
>
>_________________________________________________________________
> > > 免费下载 MSN Explorer:
> > > http://explorer.msn.com/lccn
> > >
> > > _______________________________________________
> > > python-chinese list
> > > python-chinese at lists.python.cn
> > > http://python.cn/mailman/listinfo/python-chinese
> >
> >
> >__________________________________
> >Do you Yahoo!?
> >Yahoo! Mail - More reliable, more storage, less
> spam
> >http://mail.yahoo.com
> >_______________________________________________
> >python-chinese list
> >python-chinese at lists.python.cn
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com


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

2004年03月17日 星期三 11:03

Who Bruce whoonline at msn.com
Wed Mar 17 11:03:57 HKT 2004

locale.LC_ALL just work for gettext, you can't set your environment this 
way.try .lang . My Linux system is RedHat,I don't know whether .lang exists 
in your Mandrake box. I think that changing evironment is the best way.if 
you can't find .lang,just change your .bashrc .try it or just google it.


>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:58:15 -0800 (PST)
>
>Bruce, thanks.  But as long as it works for my python
>script, it is good enough.  The thing is that I find
>it does not even work.
>
>When I call locale.setlocale(locale.LC_ALL, 'zh_CN'),
>it complains:
>
>   File "snake.py", line 4, in ?
>     locale.setlocale(locale.LC_ALL, 'zh_CN')
>   File "/usr/lib/python2.3/locale.py", line 381, in
>setlocale
>     return _setlocale(category, locale)
>locale.Error: locale setting not supported
>
>
>--- Who Bruce <whoonline at msn.com> wrote:
> > eviroment will effect the whole Mandrake system, if
> > you just use locale in
> > you Python script,it just influence your script
> > itself.
> >
> >
> > >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:44:32 -0800 (PST)
> > >
> > >Can I just call locale.setlocale(locale.LC_ALL,
> > >'zh_CN') in my python script?
> > >
> > >--- 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
> > >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
> > strings,
> > > > I
> > > > > > have a
> > > > > > >AL> problem.
> > > > > > >
> > > > > > >AL> For example, to run the following
> > script:
> > > > > > >
> > > > > > >AL> s = "蟒蛇"  # 2 Chinese
> > >characters
> > > > >for
> > > > > > >AL> python
> > > > > > >AL> s = unicode(s, 'gbk')
> > > > > > >AL> print s
> > > > > > >
> > > > > > >AL> I get the following error message.
> > > > > > >
> > > > > > >AL> [antony at ancho tmp]$ python snake.py
> > > > > > >AL> Traceback (most recent call last):
> > > > > > >AL>   File "snake.py", line 6, in ?
> > > > > > >AL>     print a
> > > > > > >AL> UnicodeEncodeError: 'latin-1' codec
> > can't
> > > > > > encode
> > > > > > >AL> characters in position 0-1: ordinal not
> > in
> > > > > > range(256)
> > > > > > >AL> [antony at ancho tmp]$
> > > > > > >
> > > > > > >AL> What is the problem please?
> > > > > > >
> > > > > > >
> > > > > > >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![
> > > > > > >  \=======================================/
> > > > > > >
> > > > > >
> > >_______________________________________________
> > > > > > >python-chinese list
> > > > > > >python-chinese at lists.python.cn
> > > > > >
> > > >
> > >http://python.cn/mailman/listinfo/python-chinese
> > > > > >
> > > > > >
> > > >
> > >
> >
> >_________________________________________________________________
> > > > > > 免费下载 MSN
>Explorer:
> > > > > > http://explorer.msn.com/lccn
> > > > > >
> > > > > >
> > _______________________________________________
> > > > > > python-chinese list
> > > > > > python-chinese at lists.python.cn
> > > > > >
> > http://python.cn/mailman/listinfo/python-chinese
> > > > >
> > > > >
> > > > >__________________________________
> > > > >Do you Yahoo!?
> > > > >Yahoo! Mail - More reliable, more storage, less
> > > > spam
> > > > >http://mail.yahoo.com
> > > > >_______________________________________________
> > > > >python-chinese list
> > > > >python-chinese at lists.python.cn
> > > >
> > >http://python.cn/mailman/listinfo/python-chinese
> > > >
> > > >
> >
> >_________________________________________________________________
> > > > 免费下载 MSN Explorer:
> > > > http://explorer.msn.com/lccn
> > > >
> > > > _______________________________________________
> > > > python-chinese list
> > > > python-chinese at lists.python.cn
> > > > http://python.cn/mailman/listinfo/python-chinese
> > >
> > >
> > >__________________________________
> > >Do you Yahoo!?
> > >Yahoo! Mail - More reliable, more storage, less
> > spam
> > >http://mail.yahoo.com
> > >_______________________________________________
> > >python-chinese list
> > >python-chinese at lists.python.cn
> >
>=== message truncated ===
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Mail - More reliable, more storage, less spam
>http://mail.yahoo.com
>_______________________________________________
>python-chinese list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese

_________________________________________________________________
免费下载 MSN Explorer:   http://explorer.msn.com/lccn  



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

2004年03月17日 星期三 11:26

Anthony Liu antonyliu2002 at yahoo.com
Wed Mar 17 11:26:40 HKT 2004

I have been intensively searching google, but kind
find helpful information on how to set LANG.

I issued

set LANG = zh_CN

at command line, but then env still shows that 

LANG=en_US

--- Who Bruce <whoonline at msn.com> wrote:
> locale.LC_ALL just work for gettext, you can't set
> your environment this 
> way.try .lang . My Linux system is RedHat,I don't
> know whether .lang exists 
> in your Mandrake box. I think that changing
> evironment is the best way.if 
> you can't find .lang,just change your .bashrc .try
> it or just google it.
> 
> 
> >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:58:15 -0800 (PST)
> >
> >Bruce, thanks.  But as long as it works for my
> python
> >script, it is good enough.  The thing is that I
> find
> >it does not even work.
> >
> >When I call locale.setlocale(locale.LC_ALL,
> 'zh_CN'),
> >it complains:
> >
> >   File "snake.py", line 4, in ?
> >     locale.setlocale(locale.LC_ALL, 'zh_CN')
> >   File "/usr/lib/python2.3/locale.py", line 381,
> in
> >setlocale
> >     return _setlocale(category, locale)
> >locale.Error: locale setting not supported
> >
> >
> >--- Who Bruce <whoonline at msn.com> wrote:
> > > eviroment will effect the whole Mandrake system,
> if
> > > you just use locale in
> > > you Python script,it just influence your script
> > > itself.
> > >
> > >
> > > >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:44:32 -0800 (PST)
> > > >
> > > >Can I just call locale.setlocale(locale.LC_ALL,
> > > >'zh_CN') in my python script?
> > > >
> > > >--- 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
> > > >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
> > > strings,
> > > > > I
> > > > > > > have a
> > > > > > > >AL> problem.
> > > > > > > >
> > > > > > > >AL> For example, to run the following
> > > script:
> > > > > > > >
> > > > > > > >AL> s = "蟒蛇"  # 2 Chinese
> > > >characters
> > > > > >for
> > > > > > > >AL> python
> > > > > > > >AL> s = unicode(s, 'gbk')
> > > > > > > >AL> print s
> > > > > > > >
> > > > > > > >AL> I get the following error message.
> > > > > > > >
> > > > > > > >AL> [antony at ancho tmp]$ python snake.py
> > > > > > > >AL> Traceback (most recent call last):
> > > > > > > >AL>   File "snake.py", line 6, in ?
> > > > > > > >AL>     print a
> > > > > > > >AL> UnicodeEncodeError: 'latin-1' codec
> > > can't
> > > > > > > encode
> > > > > > > >AL> characters in position 0-1: ordinal
> not
> > > in
> > > > > > > range(256)
> > > > > > > >AL> [antony at ancho tmp]$
> > > > > > > >
> > > > > > > >AL> What is the problem please?
> > > > > > > >
> > > > > > > >
> > > > > > > >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 truncated ===


__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com


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

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

    你的回复:

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

    Zeuux © 2024

    京ICP备05028076号