2007年09月06日 星期四 16:04
*µ±ÎÒ°ÑÊý¾Ý¿âÀï¶Á³öµÄÒ»ÌõÊý¾Ý·Åµ½±íµ¥Àïʱ£¬Óöµ½ÁËÎÊÌ⣺* ** def edit(num): lst=[] lst=dbAccess.RunSelect("select * from contract where id=%s" % num) print "" ´íÎóÈçÏ£º *¿´À´ÊDZàÂëÓÐÎÊÌâ* *Error in /contract/index.ks/edit* Script */contract/index.ks/edit* ------------------------------ UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128) Line 51 print "ÖÐÎÄÐÕÃû:
2007年09月06日 星期四 16:20
Êý¾Ý¿âµÃµ½µÄ¿ÉÄÜÊÇunicode,¶øÄãʹÓà print 'ÖÐÎÄ' + unicode stringʱ,python»á×Ô¶¯½«strתΪunicode,µ«ÊÇËüÒ»°ãÊÇʹÓÃascii(ÔÚsite.pyÖÐÉèÖÃ)À´×ª»», ËùÒÔ¶ÔÓÚÖÐÎÄת»»»áʧ°Ü.·½·¨Óкܶà: 1. ÔÚ³ÌÐòÇ°Ãæ¼ÓÉÏ #coding = utf-8Ö®ÀàµÄÉùÃ÷,È»ºóÕû¸öÎļþ±£´æΪÏàÓ¦µÄ±àÂë,È»ºóÔÙ°ÑËùÓÐstringÇ°Ãæ¼ÓÉÏuÀ´ÉùÃ÷Ϊunicode 2. ÊÖ¹¤×ª»»,ÔÚËùÓÐstringÇ°¼ÓÉÏunicode('ÖÐÎÄ', encoding),ÕâÀïencodingÓëÄãµÄÎļþʹÓõıàÂëÏàͬ 3. reload(sys) sys.setdefaultencoding('encoding') ÕâÀïencodingΪÄãÎļþµÄ±àÂë.ÕâÑùת»»Ó¦¸Ã¾ÍûÓÐÎÊÌâÁË. ÍƼöµÚÒ»ÖÖ. On 9/6/07, klutz chump <chumpklutz在gmail.com> wrote: > > *µ±ÎÒ°ÑÊý¾Ý¿âÀï¶Á³öµÄÒ»ÌõÊý¾Ý·Åµ½±íµ¥Àïʱ£¬Óöµ½ÁËÎÊÌ⣺* > ** > def edit(num): > lst=[] > lst=dbAccess.RunSelect("select * from contract where id=%s" % num) > print "" > > ´íÎóÈçÏ£º > *¿´À´ÊDZàÂëÓÐÎÊÌâ* > *Error in /contract/index.ks/edit* > > Script */contract/index.ks/edit* > ------------------------------ > UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128) > > Line 51 > print "ÖÐÎÄÐÕÃû:
2007年09月06日 星期四 16:21
On 9/6/07, klutz chump <chumpklutz在gmail.com> wrote: > > µ±ÎÒ°ÑÊý¾Ý¿âÀï¶Á³öµÄÒ»ÌõÊý¾Ý·Åµ½±íµ¥Àïʱ£¬Óöµ½ÁËÎÊÌ⣺ > > def edit(num): > lst=[] > lst=dbAccess.RunSelect("select * from contract where id=%s" % num) > print "" > > ´íÎóÈçÏ£º > ¿´À´ÊDZàÂëÓÐÎÊÌâ > Error in /contract/index.ks/edit > > > Script /contract/index.ks/edit________________________________ UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128) Line 51 print "ÖÐÎÄÐÕÃû:
2007年09月06日 星期四 17:05
ʹÓõÚÒ»Ìõ¾Í½â¾öÎÊÌâÁË£¬Ð»Ð»ÀÏÀî ÔÚ07-9-6£¬limodou <limodou在gmail.com> дµÀ£º > > Êý¾Ý¿âµÃµ½µÄ¿ÉÄÜÊÇunicode,¶øÄãʹÓà print 'ÖÐÎÄ' + unicode > stringʱ,python»á×Ô¶¯½«strתΪunicode,µ«ÊÇËüÒ»°ãÊÇʹÓÃascii(ÔÚsite.pyÖÐÉèÖÃ)À´×ª»», > ËùÒÔ¶ÔÓÚÖÐÎÄת»»»áʧ°Ü.·½·¨Óкܶà: > > 1. ÔÚ³ÌÐòÇ°Ãæ¼ÓÉÏ #coding = > utf-8Ö®ÀàµÄÉùÃ÷,È»ºóÕû¸öÎļþ±£´æΪÏàÓ¦µÄ±àÂë,È»ºóÔÙ°ÑËùÓÐstringÇ°Ãæ¼ÓÉÏuÀ´ÉùÃ÷Ϊunicode > 2. ÊÖ¹¤×ª»»,ÔÚËùÓÐstringÇ°¼ÓÉÏunicode('ÖÐÎÄ', encoding),ÕâÀïencodingÓëÄãµÄÎļþʹÓõıàÂëÏàͬ > 3. reload(sys) > sys.setdefaultencoding('encoding') > > ÕâÀïencodingΪÄãÎļþµÄ±àÂë.ÕâÑùת»»Ó¦¸Ã¾ÍûÓÐÎÊÌâÁË. > > ÍƼöµÚÒ»ÖÖ. > > On 9/6/07, klutz chump < chumpklutz在gmail.com> wrote: > > > *µ±ÎÒ°ÑÊý¾Ý¿âÀï¶Á³öµÄÒ»ÌõÊý¾Ý·Åµ½±íµ¥Àïʱ£¬Óöµ½ÁËÎÊÌ⣺* > > ** > > def edit(num): > > lst=[] > > lst=dbAccess.RunSelect("select * from contract where id=%s" % num) > > print "" > > > > ´íÎóÈçÏ£º > > *¿´À´ÊDZàÂëÓÐÎÊÌâ* > > *Error in /contract/index.ks/edit* > > > > Script */contract/index.ks/edit* > > ------------------------------ > > UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128) > > > > Line 51 > > print "ÖÐÎÄÐÕÃû:
Zeuux © 2025
京ICP备05028076号