2008年01月03日 星期四 18:53
#!/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, inprint 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
2008年01月03日 星期四 19:41
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
2008年01月03日 星期四 19:51
ÎÊÌâÓÖ³öÏÖÁË£¬Ô´´úÂëÈçÏ£º 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, inprint 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
2008年01月03日 星期四 19:52
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
Zeuux © 2024
京ICP备05028076号