Python论坛  - 讨论区

标题:[python-chinese] ulipad编码

2008年01月03日 星期四 18:53

zinicl zinicl在gmail.com
星期四 一月 3 18:53:25 HKT 2008

#!/usr/bin/env python
#coding=utf-8

if __name__ == '__main__':
    print u'ÄãºÃ'

ÔÚÃüÁîÐÐÏ¿ÉÒÔÕýÈ·ÏÔʾ½á¹û£¬ÔÚulipadÏÂÏÔʾ£º
> "C:\Python25\python.exe" -u "D:\Source\test.py"
Traceback (most recent call last):
  File "D:\Source\test.py", line 5, in 
    print u'你好'
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1:
ordinal not in range(128)
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20080103/91d0bf35/attachment.htm 

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

2008年01月03日 星期四 19:41

limodou limodou在gmail.com
星期四 一月 3 19:41:11 HKT 2008

On Jan 3, 2008 6:53 PM, zinicl <zinicl在gmail.com> wrote:
> #!/usr/bin/env python
> #coding=utf-8
>
> if __name__ == '__main__':
>     print u'ÄãºÃ'
>
> ÔÚÃüÁîÐÐÏ¿ÉÒÔÕýÈ·ÏÔʾ½á¹û£¬ÔÚulipadÏÂÏÔʾ£º
> > "C:\Python25\python.exe" -u "D:\Source\test.py"
> Traceback (most recent call last):
>   File "D:\Source\test.py", line 5, in 
>     print u'你好'
> UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1:
> ordinal not in range(128)
>
>
°´F5Ö´ÐеĻ°£¬ÆäʵÊǵ÷ÓÃÁËpython½âÊÍÆ÷ÔÚÒ»¸öеĽø³ÌÖÐÔËÐеijÌÐò£¬¶ø½á¹ûÔòͨ¹ýÊäÈëÊä³öÖض¨Ïò½øÐÐÊä³ö¡£Òò´ËÔÚÊä³öʱÈç¹ûÊÇunicode£¬ÔòÊä³öÖض¨Ïò»á³ö´í¡£Òò´ËÉÏÃæµÄprint¿ÉÒÔ¸ÄΪ£º

print u'ÄãºÃ'.encode('gb2312')

²¢ÇÒÖ®ËùÒÔÄã¿´µ½ÊÇ

print u'你好'

ÕâÊÇÒòΪÄãµÄÔ´Îļþ±àÂëÉùÃ÷Ϊutf-8£¬¶øutf-8ÔÚgb2312µÄÃüÁîÐÐÉÏÏÔʾ¾ÍÊÇÂÒÂ룬ÕâÊǶԵġ£

-- 
I like python!
UliPad <>: http://code.google.com/p/ulipad/
meide <>: http://code.google.com/p/meide/
My Blog: http://www.donews.net/limodou

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

2008年01月03日 星期四 19:51

zinicl zinicl在gmail.com
星期四 一月 3 19:51:15 HKT 2008

ÎÊÌâÓÖ³öÏÖÁË£¬Ô´´úÂëÈçÏ£º
HOST = "127.0.0.1"
    PORT = 8001

    print u'ÇëÊäÈëÖ÷»úµØÖ·£¬·ñÔòʹÓÃĬÈϵØÖ·['+HOST+']:'.encode('gbk'),

ÃüÁîÐÐÖ´ÐÐÕý³££¬µ«ÊÇÔÚulipadÖÐÏÔʾ£º
> "C:\Python25\python.exe" -u "D:\Source\testquote\testquote.py"
Traceback (most recent call last):
  File "D:\Source\testquote\testquote.py", line 93, in 
    print
u'\xe8\xaf\xb7\xe8\xbe\x93\xe5\x85\xa5\xe4\xb8\xbb\xe6\x9c\xba\xe5\x9c\xb0\xe5\x9d\x80\xef\xbc\x8c\xe5\x90\xa6\xe5\x88\x99\xe4\xbd\xbf\xe7\x94\xa8\xe9\xbb\x98\xe8\xae\xa4\xe5\x9c\xb0\xe5\x9d\x80['+HOST+']:'.encode('gb2312'),
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-15:
ordinal not in range(128)


ÔÚ08-1-3£¬limodou <limodou在gmail.com> дµÀ£º
>
> On Jan 3, 2008 6:53 PM, zinicl <zinicl在gmail.com> wrote:
> > #!/usr/bin/env python
> > #coding=utf-8
> >
> > if __name__ == '__main__':
> >     print u'ÄãºÃ'
> >
> > ÔÚÃüÁîÐÐÏ¿ÉÒÔÕýÈ·ÏÔʾ½á¹û£¬ÔÚulipadÏÂÏÔʾ£º
> > > "C:\Python25\python.exe" -u "D:\Source\test.py"
> > Traceback (most recent call last):
> >   File "D:\Source\test.py", line 5, in 
> >     print u'你好'
> > UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 0-1:
> > ordinal not in range(128)
> >
> >
>
> °´F5Ö´ÐеĻ°£¬ÆäʵÊǵ÷ÓÃÁËpython½âÊÍÆ÷ÔÚÒ»¸öеĽø³ÌÖÐÔËÐеijÌÐò£¬¶ø½á¹ûÔòͨ¹ýÊäÈëÊä³öÖض¨Ïò½øÐÐÊä³ö¡£Òò´ËÔÚÊä³öʱÈç¹ûÊÇunicode£¬ÔòÊä³öÖض¨Ïò»á³ö´í¡£Òò´ËÉÏÃæµÄprint¿ÉÒÔ¸ÄΪ£º
>
> print u'ÄãºÃ'.encode('gb2312')
>
> ²¢ÇÒÖ®ËùÒÔÄã¿´µ½ÊÇ
>
> print u'你好'
>
> ÕâÊÇÒòΪÄãµÄÔ´Îļþ±àÂëÉùÃ÷Ϊutf-8£¬¶øutf-8ÔÚgb2312µÄÃüÁîÐÐÉÏÏÔʾ¾ÍÊÇÂÒÂ룬ÕâÊǶԵġ£
>
> --
> I like python!
> UliPad <>: http://code.google.com/p/ulipad/
> meide <>: http://code.google.com/p/meide/
> My Blog: http://www.donews.net/limodou
>
> _______________________________________________
> 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
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20080103/6b49413d/attachment-0001.html 

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

2008年01月03日 星期四 19:52

zinicl zinicl在gmail.com
星期四 一月 3 19:52:27 HKT 2008

sorry£¬ÊÇÎÒ×Ô¼ºµÄÔ­Òò£¬Ó¦¸ÃÊÇ£º
print u'ÇëÊäÈëÖ÷»úµØÖ·£¬·ñÔòʹÓÃĬÈϵØÖ·['.encode('gb2312')+HOST+']:'.encode('gb2312'),

ÔÚ08-1-3£¬zinicl <zinicl在gmail.com> дµÀ£º
>
> ÎÊÌâÓÖ³öÏÖÁË£¬Ô´´úÂëÈçÏ£º
> HOST = "127.0.0.1"
>     PORT = 8001
>
>     print u'ÇëÊäÈëÖ÷»úµØÖ·£¬·ñÔòʹÓÃĬÈϵØÖ·['+HOST+']:'.encode('gbk'),
>
> ÃüÁîÐÐÖ´ÐÐÕý³££¬µ«ÊÇÔÚulipadÖÐÏÔʾ£º
> > "C:\Python25\python.exe" -u "D:\Source\testquote\testquote.py"
> Traceback (most recent call last):
>   File "D:\Source\testquote\testquote.py", line 93, in 
>     print
> u'\xe8\xaf\xb7\xe8\xbe\x93\xe5\x85\xa5\xe4\xb8\xbb\xe6\x9c\xba\xe5\x9c\xb0\xe5\x9d\x80\xef\xbc\x8c\xe5\x90\xa6\xe5\x88\x99\xe4\xbd\xbf\xe7\x94\xa8\xe9\xbb\x98\xe8\xae\xa4\xe5\x9c\xb0\xe5\x9d\x80['+HOST+']:'.encode('gb2312'),
>
> UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 0-15: ordinal not in range(128)
>
>
> ÔÚ08-1-3£¬limodou < limodou在gmail.com> дµÀ£º
> >
> > On Jan 3, 2008 6:53 PM, zinicl < zinicl在gmail.com> wrote:
> > > #!/usr/bin/env python
> > > #coding=utf-8
> > >
> > > if __name__ == '__main__':
> > >     print u'ÄãºÃ'
> > >
> > > ÔÚÃüÁîÐÐÏ¿ÉÒÔÕýÈ·ÏÔʾ½á¹û£¬ÔÚulipadÏÂÏÔʾ£º
> > > > "C:\Python25\python.exe" -u "D:\Source\test.py"
> > > Traceback (most recent call last):
> > >   File "D:\Source\test.py", line 5, in 
> > >     print u'你好'
> > > UnicodeEncodeError: 'ascii' codec can't encode characters in position
> > 0-1:
> > > ordinal not in range(128)
> > >
> > >
> >
> > °´F5Ö´ÐеĻ°£¬ÆäʵÊǵ÷ÓÃÁËpython½âÊÍÆ÷ÔÚÒ»¸öеĽø³ÌÖÐÔËÐеijÌÐò£¬¶ø½á¹ûÔòͨ¹ýÊäÈëÊä³öÖض¨Ïò½øÐÐÊä³ö¡£Òò´ËÔÚÊä³öʱÈç¹ûÊÇunicode£¬ÔòÊä³öÖض¨Ïò»á³ö´í¡£Òò´ËÉÏÃæµÄprint¿ÉÒÔ¸ÄΪ£º
> >
> > print u'ÄãºÃ'.encode('gb2312')
> >
> > ²¢ÇÒÖ®ËùÒÔÄã¿´µ½ÊÇ
> >
> > print u'你好'
> >
> > ÕâÊÇÒòΪÄãµÄÔ´Îļþ±àÂëÉùÃ÷Ϊutf-8£¬¶øutf-8ÔÚgb2312µÄÃüÁîÐÐÉÏÏÔʾ¾ÍÊÇÂÒÂ룬ÕâÊǶԵġ£
> >
> > --
> > I like python!
> > UliPad <>: http://code.google.com/p/ulipad/
> > meide <>: http://code.google.com/p/meide/
> > My Blog: http://www.donews.net/limodou
> >
> > _______________________________________________
> > 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
> >
>
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20080103/dc6902b5/attachment.htm 

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

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

    你的回复:

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

    Zeuux © 2024

    京ICP备05028076号