Python论坛  - 讨论区

标题:[python-chinese] 用emacs的进来一下

2008年01月01日 星期二 03:02

lee flyli3415在gmail.com
星期二 一月 1 03:02:45 HKT 2008

ǰ¼¸Ìì¿´µ½ÓÐÈËÍÆ¼öemacs ¾ÍÊÔÓÃÁËÏÂ

windowsÏÂ

ÔÚemacsµÄshellÏÂÔËÐÐpython½Å±¾µÄʱºò»á³öÏÖuniocde´íÎó
±ÈÈç test.pyÀïÓÐÈçÏÂÄÚÈÝ:

a=u'ÄãºÃ'
print a

ÔÚemacsµÄshellÀïÔËÐÐ python test.py ±¨´í£º
Traceback (most recent call last):
  File "test.py", line 28, in 
    print a
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1:
ordinal not in range(128)

µ«ÊÇÔÚwindowsµÄcmdÀïÔËÐÐÔòÕý³£

ÓÐÓöµ½¹ýͬÑùÇé¿öµÄô£¿
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20080101/f8a7789d/attachment.htm 

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

2008年01月01日 星期二 17:24

Ben Luo benluo在gmail.com
星期二 一月 1 17:24:24 HKT 2008

On Jan 1, 2008 3:02 AM, lee <flyli3415在gmail.com> wrote:

> ǰ¼¸Ìì¿´µ½ÓÐÈËÍÆ¼öemacs ¾ÍÊÔÓÃÁËÏÂ
>
> windowsÏÂ
>
> ÔÚemacsµÄshellÏÂÔËÐÐpython½Å±¾µÄʱºò»á³öÏÖuniocde´íÎó
> ±ÈÈç test.pyÀïÓÐÈçÏÂÄÚÈÝ:
>
> a=u'ÄãºÃ'
> print a
>
> ÔÚemacsµÄshellÀïÔËÐÐ python test.py ±¨´í£º
> Traceback (most recent call last):
>   File "test.py", line 28, in 
>     print a
> UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1:
> ordinal not in range(128)
>
> µ«ÊÇÔÚwindowsµÄcmdÀïÔËÐÐÔòÕý³£
>
> ÓÐÓöµ½¹ýͬÑùÇé¿öµÄô£¿
>
ÄãµÄÎļþÀïûÓж¨Òåutf8
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20080101/813951c0/attachment.html 

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

2008年01月01日 星期二 20:55

liwei anbutu在gmail.com
星期二 一月 1 20:55:19 HKT 2008

文件开始的地方写上文件编码类型
# *-* coding: utf-8 *-*

On Jan 1, 2008 5:24 PM, Ben Luo <benluo在gmail.com> wrote:
>
>
> On Jan 1, 2008 3:02 AM, lee <flyli3415在gmail.com> wrote:
> >
> > 前几天看到有人推荐emacs 就试用了下
> >
> > windows下
> >
> > 在emacs的shell下运行python脚本的时候会出现uniocde错误
> > 比如 test.py里有如下内容:
> >
> > a=u'你好'
> > print a
> >
> > 在emacs的shell里运行 python test.py 报错:
> > Traceback (most recent call last):
> >   File "test.py", line 28, in 
> >     print a
> > UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1:
> ordinal not in range(128)
> >
> > 但是在windows的cmd里运行则正常
> >
> > 有遇到过同样情况的么?
> 你的文件里没有定义utf8
>
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
Jerry Lee
University of Jinan

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

2008年01月01日 星期二 22:58

lee flyli3415在gmail.com
星期二 一月 1 22:58:57 HKT 2008

ÕâÑù×ö»¹ÊDz»ÐÐ
Òª°Ñ a=u'ÄãºÃ' ¸Ä³É a='ÄãºÃ'
µ«ÊÇÕâÓ¦¸Ã²»ÊÇÖ÷ÒªÎÊÌâ
Èç¹û´ÓÒ»¸öÎļþ¶ÁÈ¡unicodeµÄ×Ö·û
ÔÙÏëÒÔ print a.decode('utf-16')
¾ÍÓÖ²»ÐÐÁË µ«ÊÇÔÚIDLE £¬pythonwind£¬cmd ÏÂÊÇÕý³£µÄ£¬Ö»ÓÐemacsµÄshellϲ»Õý³£


ÔÚ08-1-1£¬Ben Luo <benluo在gmail.com> дµÀ£º
>
>  ÄãµÄÎļþÀïûÓж¨Òåutf8
>
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20080101/1bf1ed30/attachment.html 

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号