Python论坛  - 讨论区

标题:[python-chinese] 在DOS窗口显示中文的问题

2006年08月02日 星期三 14:07

唐国巍 tdavid77 at tom.com
Wed Aug 2 14:07:03 HKT 2006

我是在WIN2000下使用PYTHON2.4的,用os.walk读入一个目录下的子目录和文件,然后对这些文件再做一些处理。有的时候会出错,PYTHON会在DOS窗口给些提示,哪个目录下的哪个文件出错了,但是这时的中文文件名显示的是\x...之类的,无法知道是哪个文件出错。
请问有没有办法让DOS窗口能显示出中文名或是,通过其它什么办法能转化成中文的。
谢谢。
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060802/643d525a/attachment.htm

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

2006年08月02日 星期三 14:08

limodou limodou at gmail.com
Wed Aug 2 14:08:28 HKT 2006

On 8/2/06, 唐国巍 <tdavid77 at tom.com> wrote:
>
>
> 我是在WIN2000下使用PYTHON2.4的,用os.walk读入一个目录下的子目录和文件,然后对这些文件再做一些处理。有的时候会出错,PYTHON会在DOS窗口给些提示,哪个目录下的哪个文件出错了,但是这时的中文文件名显示的是\x...之类的,无法知道是哪个文件出错。
> 请问有没有办法让DOS窗口能显示出中文名或是,通过其它什么办法能转化成中文的。
> 谢谢。

把字符串拷贝下来,然后在命令行下存为一个字符串,打印一下就行了。
如:

print '\x\x\x'

-- 
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

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

2006年08月02日 星期三 14:44

Xiao Lei Wu xiaoleiw at cn.ibm.com
Wed Aug 2 14:44:16 HKT 2006

ÓÃtry¸ú×ÙÕâ¸ö´íÎó£¬È»ºóexceptÀïÃæÓÃprint´ò³öÀ´£¬¸ø¸öÀý×Ó£¬×Ô¼º·¢»Ó£º
    except:
        print 'Error:'
        print "%s: %s" % (sys.exc_type, sys.exc_value)

Best Regards,

Zachary Wu (Îâ°~ÀÚ)
Software Engineer, Enterprise Content Management FVT, IBM China Software
Development Lab
Tel: +86 10 82782244-3235. Fax: 82782244-2886 Tie Line: 915-2244-3235
Internet: xiaoleiw at cn.ibm.com
Notes ID: Xiao Lei Wu/China/Contr/IBM at IBMCN
Address: 8/F, Block A, Power Creative Building, No.1, East Road, Shang Di,
Beijing 100085, P.R. China

python-chinese-bounces at lists.python.cn дÓÚ 2006-08-02 14:07:03:

> ÎÒÊÇÔÚWIN2000ÏÂʹÓÃPYTHON2.4µÄ£¬ÓÃos.walk¶ÁÈëÒ»¸öĿ¼ÏµÄ×ÓĿ¼ºÍÎÄ
> ¼þ£¬È»ºó¶ÔÕâЩÎļþÔÙ×öһЩ´¦Àí¡£ÓеÄʱºò»á³ö´í£¬PYTHON»áÔÚDOS´°¿Ú¸ø
> ЩÌáʾ£¬ÄĸöĿ¼ÏµÄÄĸöÎļþ³ö´íÁË£¬µ«ÊÇÕâʱµÄÖÐÎÄÎļþÃûÏÔʾµÄÊÇ
> \x...Ö®ÀàµÄ£¬ÎÞ·¨ÖªµÀÊÇÄĸöÎļþ³ö´í¡£
> ÇëÎÊÓÐûÓа취ÈÃDOS´°¿ÚÄÜÏÔʾ³öÖÐÎÄÃû»òÊÇ£¬Í¨¹ýÆäËüʲô°ì·¨ÄÜת»¯³ÉÖÐÎÄ
µÄ¡£
> лл¡£_______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060802/243b7dbc/attachment.html

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

2006年08月02日 星期三 16:18

唐国巍 tdavid77 at tom.com
Wed Aug 2 16:18:25 HKT 2006

¹ûÈ»¿ÉÒÔ£¬Ð»Ð»ÁË¡£
  ----- Original Message ----- 
  From: Xiao Lei Wu 
  To: python-chinese at lists.python.cn 
  Sent: Wednesday, August 02, 2006 2:44 PM
  Subject: Re: [python-chinese] ÔÚDOS´°¿ÚÏÔʾÖÐÎĵÄÎÊÌâ


  ÓÃtry¸ú×ÙÕâ¸ö´íÎó£¬È»ºóexceptÀïÃæÓÃprint´ò³öÀ´£¬¸ø¸öÀý×Ó£¬×Ô¼º·¢»Ó£º
  except:
  print 'Error:'
  print "%s: %s" % (sys.exc_type, sys.exc_value)

  Best Regards,

  Zachary Wu (Îâ°~ÀÚ)
  Software Engineer, Enterprise Content Management FVT, IBM China Software Development Lab
  Tel: +86 10 82782244-3235. Fax: 82782244-2886 Tie Line: 915-2244-3235
  Internet: xiaoleiw at cn.ibm.com 
  Notes ID: Xiao Lei Wu/China/Contr/IBM at IBMCN
  Address: 8/F, Block A, Power Creative Building, No.1, East Road, Shang Di, Beijing 100085, P.R. China

  python-chinese-bounces at lists.python.cn дÓÚ 2006-08-02 14:07:03:

  > ÎÒÊÇÔÚWIN2000ÏÂʹÓÃPYTHON2.4µÄ£¬ÓÃos.walk¶ÁÈëÒ»¸öĿ¼ÏµÄ×ÓĿ¼ºÍÎÄ
  > ¼þ£¬È»ºó¶ÔÕâЩÎļþÔÙ×öһЩ´¦Àí¡£ÓеÄʱºò»á³ö´í£¬PYTHON»áÔÚDOS´°¿Ú¸ø
  > ЩÌáʾ£¬ÄĸöĿ¼ÏµÄÄĸöÎļþ³ö´íÁË£¬µ«ÊÇÕâʱµÄÖÐÎÄÎļþÃûÏÔʾµÄÊÇ
  > \x...Ö®ÀàµÄ£¬ÎÞ·¨ÖªµÀÊÇÄĸöÎļþ³ö´í¡£
  > ÇëÎÊÓÐûÓа취ÈÃDOS´°¿ÚÄÜÏÔʾ³öÖÐÎÄÃû»òÊÇ£¬Í¨¹ýÆäËüʲô°ì·¨ÄÜת»¯³ÉÖÐÎĵġ£
  > лл¡£_______________________________________________
  > python-chinese
  > Post: send python-chinese at lists.python.cn
  > Subscribe: send subscribe to python-chinese-request at lists.python.cn
  > Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
  > Detail Info: http://python.cn/mailman/listinfo/python-chinese



------------------------------------------------------------------------------


  _______________________________________________
  python-chinese
  Post: send python-chinese at lists.python.cn
  Subscribe: send subscribe to python-chinese-request at lists.python.cn
  Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
  Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060802/02e10e94/attachment.html

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号