Python论坛  - 讨论区

标题:[python-chinese] Karrigell表单输出问题

2007年09月06日 星期四 16:04

klutz chump chumpklutz在gmail.com
星期四 九月 6 16:04:40 HKT 2007

*µ±ÎÒ°ÑÊý¾Ý¿âÀï¶Á³öµÄÒ»ÌõÊý¾Ý·Åµ½±íµ¥Àïʱ£¬Óöµ½ÁËÎÊÌ⣺*
**
def edit(num):
 lst=[]
 lst=dbAccess.RunSelect("select * from contract where id=%s" % num)
 print "
" print "" % num print "ÖÐÎÄÐÕÃû:
" % lst[0][2] print "Ó¢ÎÄÐÕÃû:
" % lst[0][3] print "š„Õ :
" % lst[0][4] print "¹«Ë¾ :
" % lst[0][5] print "" 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 "ÖÐÎÄÐÕÃû:
" % lst[0][2] Traceback (most recent call last): File "D:\Karrigell-2.3.4\core\k_script.py", line 145, in render self.run_script(ns) File "D:\Karrigell-2.3.4\modules\mod_ks.py", line 64, in run_script exec("%s(%s)" %(function,args)) in ns File "", line 1, in File "", line 51, in edit UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128) -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070906/665944be/attachment-0001.html

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

2007年09月06日 星期四 16:20

limodou limodou在gmail.com
星期四 九月 6 16:20:30 HKT 2007

Êý¾Ý¿âµÃµ½µÄ¿ÉÄÜÊÇ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 "
" > print "" % num > print "ÖÐÎÄÐÕÃû:
" % lst[0][2]
> print "Ó¢ÎÄÐÕÃû:
" % lst[0][3]
> print "š„Õ :
" % lst[0][4]
> print "¹«Ë¾ :
" % lst[0][5]
> print "" > 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 "ÖÐÎÄÐÕÃû:
" % lst[0][2]
> > Traceback (most recent call last): > File "D:\Karrigell-2.3.4\core\k_script.py", line 145, in render > self.run_script(ns) > File "D:\Karrigell-2.3.4\modules\mod_ks.py", line 64, in run_script > exec("%s(%s)" %(function,args)) in ns > File "", line 1, in > File "", line 51, in edit > UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128) > > > _______________________________________________ > 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 > -- I like python! UliPad <>: http://code.google.com/p/ulipad/ My Blog: http://www.donews.net/limodou -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070906/5f2e00d9/attachment.htm

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

2007年09月06日 星期四 16:21

lveax lveax.m在gmail.com
星期四 九月 6 16:21:07 HKT 2007

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 "
" > print "" % num > print "ÖÐÎÄÐÕÃû:
" % lst[0][2]
> print "Ó¢ÎÄÐÕÃû:
" % lst[0][3]
> print "š„Õ :
" % lst[0][4]
> print "¹«Ë¾ :
" % lst[0][5]
> print "" > 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 "ÖÐÎÄÐÕÃû:
" % lst[0][2] print u"ÖÐÎÄÐÕÃû:
" # -*-coding:UTF-8-*- ¼Óµ½Îļþ¿ªÍ·?

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

2007年09月06日 星期四 17:05

klutz chump chumpklutz在gmail.com
星期四 九月 6 17:05:17 HKT 2007

ʹÓõÚÒ»Ìõ¾Í½â¾öÎÊÌâÁË£¬Ð»Ð»ÀÏÀî

ÔÚ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 "
" > > print "" % num > > print "ÖÐÎÄÐÕÃû:
" % lst[0][2]
> > print "Ó¢ÎÄÐÕÃû:
" % lst[0][3]
> > print "š„Õ :
" % lst[0][4]
> > print "¹«Ë¾ :
" % lst[0][5]
> > print "" > > 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 "ÖÐÎÄÐÕÃû:
" % lst[0][2]
> > > > Traceback (most recent call last): > > File "D:\Karrigell-2.3.4\core\k_script.py", line 145, in render > > self.run_script(ns) > > File "D:\Karrigell-2.3.4\modules\mod_ks.py > > ", line 64, in run_script > > exec("%s(%s)" %(function,args)) in ns > > File "", line 1, in > > File "", line 51, in edit > > UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128) > > > > > > _______________________________________________ > > 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 > > > > > > -- > I like python! > UliPad <>: http://code.google.com/p/ulipad/ > 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/20070906/593dfbc6/attachment.html

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号