Python论坛  - 讨论区

标题:[python-chinese] Chinese display problem

2005年10月14日 星期五 13:40

Anthony Liu antonyliu2002 at yahoo.com
Fri Oct 14 13:40:22 HKT 2005

I am kinda new to python, especially when I have to
process Chinese.

My python script reads a few lines from a Chinese text
and then split them by using white spaces as the
delimiters.

I got lists like:

['\xbc\xc7\xd5\xdf', '\xd0\xbb\xbd\xf0\xbb\xa2',
'\xa1\xa2']

I have 

#-*- coding: gbk -*-

on top of the script.

What else do I need to do please?

Thanks a lot!



	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

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

2005年10月14日 星期五 15:05

Fatalerr gz19990909 at 163.com
Fri Oct 14 15:05:53 HKT 2005

Hi, 
Have a try with UTF-8 instead of GBK....

Br/Jun
----- Original Message ----- 
From: "Anthony Liu" <antonyliu2002 at yahoo.com>
To: <python-chinese at lists.python.cn>
Sent: Friday, October 14, 2005 1:40 PM
Subject: [python-chinese] Chinese display problem


> I am kinda new to python, especially when I have to
> process Chinese.
> 
> My python script reads a few lines from a Chinese text
> and then split them by using white spaces as the
> delimiters.
> 
> I got lists like:
> 
> ['\xbc\xc7\xd5\xdf', '\xd0\xbb\xbd\xf0\xbb\xa2',
> '\xa1\xa2']
> 
> I have 
> 
> #-*- coding: gbk -*-
> 
> on top of the script.
> 
> What else do I need to do please?
> 
> Thanks a lot!
> 
> 
> 
> 
> 
> __________________________________ 
> Yahoo! Mail - PC Magazine Editors' Choice 2005 
> http://mail.yahoo.com
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> 
>



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

2005年10月14日 星期五 21:41

Anthony Liu antonyliu2002 at yahoo.com
Fri Oct 14 21:41:56 HKT 2005

Hi, thanks, but it did not help.

I got a list like:

['\xbc\xd3\xc7\xbf', '\xcf\xe3\xb8\xdb',
'\xbe\xad\xbc\xc3']

representing the Chinese characters.


--- Fatalerr <gz19990909 at 163.com> wrote:

> Hi, 
> Have a try with UTF-8 instead of GBK....
> 
> Br/Jun
> ----- Original Message ----- 
> From: "Anthony Liu" <antonyliu2002 at yahoo.com>
> To: <python-chinese at lists.python.cn>
> Sent: Friday, October 14, 2005 1:40 PM
> Subject: [python-chinese] Chinese display problem
> 
> 
> > I am kinda new to python, especially when I have
> to
> > process Chinese.
> > 
> > My python script reads a few lines from a Chinese
> text
> > and then split them by using white spaces as the
> > delimiters.
> > 
> > I got lists like:
> > 
> > ['\xbc\xc7\xd5\xdf', '\xd0\xbb\xbd\xf0\xbb\xa2',
> > '\xa1\xa2']
> > 
> > I have 
> > 
> > #-*- coding: gbk -*-
> > 
> > on top of the script.
> > 
> > What else do I need to do please?
> > 
> > Thanks a lot!
> > 
> > 
> > 
> > 
> > 
> > __________________________________ 
> > Yahoo! Mail - PC Magazine Editors' Choice 2005 
> > http://mail.yahoo.com
> > _______________________________________________
> > python-chinese list
> > python-chinese at lists.python.cn
> > http://python.cn/mailman/listinfo/python-chinese
> > 
> >
> 
> 
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> 



	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

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

2005年10月14日 星期五 21:50

makeyunbad makeyunbad at gmail.com
Fri Oct 14 21:50:59 HKT 2005

2005/10/14, Anthony Liu <antonyliu2002 at yahoo.com>:
> I am kinda new to python, especially when I have to
> process Chinese.
>
> My python script reads a few lines from a Chinese text
> and then split them by using white spaces as the
> delimiters.
>
> I got lists like:
>
> ['\xbc\xc7\xd5\xdf', '\xd0\xbb\xbd\xf0\xbb\xa2',
> '\xa1\xa2']
>
> I have
>
> #-*- coding: gbk -*-
>
> on top of the script.
>
> What else do I need to do please?
>

>>> a =['\xbc\xd3\xc7\xbf', '\xcf\xe3\xb8\xdb','\xbe\xad\xbc\xc3']

>>> for i in a:
... 	print i
... 	
加强
香港
经济

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

2005年10月14日 星期五 23:20

Anthony Liu antonyliu2002 at yahoo.com
Fri Oct 14 23:20:32 HKT 2005

--- makeyunbad <makeyunbad at gmail.com> wrote:

> 2005/10/14, Anthony Liu <antonyliu2002 at yahoo.com>:
> > I am kinda new to python, especially when I have
> to
> > process Chinese.
> >
> > My python script reads a few lines from a Chinese
> text
> > and then split them by using white spaces as the
> > delimiters.
> >
> > I got lists like:
> >
> > ['\xbc\xc7\xd5\xdf', '\xd0\xbb\xbd\xf0\xbb\xa2',
> > '\xa1\xa2']
> >
> > I have
> >
> > #-*- coding: gbk -*-
> >
> > on top of the script.
> >
> > What else do I need to do please?
> >
> 
> >>> a =['\xbc\xd3\xc7\xbf',
> '\xcf\xe3\xb8\xdb','\xbe\xad\xbc\xc3']
> 
> >>> for i in a:
> ... 	print i
> ... 	
> ¼ÓÇ¿
> Ïã¸Û
> ¾­¼Ã

Hehe, you are smart.  But do you know how to properly
read and write out and display Chinese with Python?



	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

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

2005年10月14日 星期五 23:34

kebo wang kebowang at gmail.com
Fri Oct 14 23:34:10 HKT 2005

2005/10/14, Anthony Liu <antonyliu2002 at yahoo.com>:
> Hehe, you are smart.  But do you know how to properly
> read and write out and display Chinese with Python?

你的运行环境?

--
Bset Regards,
Kebo Wang

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

2005年10月15日 星期六 00:11

Jason Liu telecomliu at gmail.com
Sat Oct 15 00:11:52 HKT 2005

2005/10/14, Anthony Liu <antonyliu2002 at yahoo.com>:
> I am kinda new to python, especially when I have to
> process Chinese.
>
> My python script reads a few lines from a Chinese text
> and then split them by using white spaces as the
> delimiters.
>
> I got lists like:
>
> ['\xbc\xc7\xd5\xdf', '\xd0\xbb\xbd\xf0\xbb\xa2',
> '\xa1\xa2']
>
> I have
>
> #-*- coding: gbk -*-
>
> on top of the script.
>
> What else do I need to do please?
>
> Thanks a lot!
>

try to print items of the list one by one

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

2005年10月15日 星期六 01:04

Anthony Liu antonyliu2002 at yahoo.com
Sat Oct 15 01:04:08 HKT 2005

O, thanks.

It's a Windows 2000 Server, English version, service
pack 4(? forgot), but the default language is set to
be Chinese (GB2312).

Actually I also wanna be able to process Chinese
properly on a Mandrake system.

--- kebo wang <kebowang at gmail.com> wrote:

> 2005/10/14, Anthony Liu <antonyliu2002 at yahoo.com>:
> > Hehe, you are smart.  But do you know how to
> properly
> > read and write out and display Chinese with
> Python?
> 
> ÄãµÄÔËÐл·¾³£¿
> 
> --
> Bset Regards,
> Kebo Wang
> > _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> 



		
__________________________________ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs

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

2005年10月15日 星期六 08:21

makeyunbad makeyunbad at gmail.com
Sat Oct 15 08:21:34 HKT 2005

2005/10/15, Anthony Liu <antonyliu2002 at yahoo.com>:
> O, thanks.
>
> It's a Windows 2000 Server, English version, service
> pack 4(? forgot), but the default language is set to
> be Chinese (GB2312).
>

Where do you want to display?
['\xbc\xc7\xd5\xdf', '\xd0\xbb\xbd\xf0\xbb\xa2','\xa1\xa2']
The list is normal in python.
>>> a =['\xbc\xd3\xc7\xbf', '\xcf\xe3\xb8\xdb','\xbe\xad\xbc\xc3']
>>> f = open('d:/log.txt','w')
>>> f.writelines(a)
>>> f.close()
When I open the file, Chinese display normal.

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号