Python论坛  - 讨论区

标题:[python-chinese] 运行程序时出错,请教!

2006年08月12日 星期六 13:59

jsz7758520 jsz7758520 at 163.com
Sat Aug 12 13:59:19 HKT 2006

我是在windown下使用python的,刚练习了一条break语句,但是出错了。

程序:

while Ture:
    s = raw_input('Enter something :')
    if s == 'quit':
        break
    print 'Length of the string is ', len(s)
print 'Done'


按F5之后,错误提示如下:
>>> Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
    return self.func(*args)
  File "C:\Python24\lib\idlelib\ScriptBinding.py", line 142, in run_module_event
    code = self.checksyntax(filename)
  File "C:\Python24\lib\idlelib\ScriptBinding.py", line 101, in checksyntax
    return compile(source, filename, "exec")
UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-32: ordinal not in range(128)


这是什么问题引起的,谢谢



jsz7758520
2006-08-12
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060812/448bb091/attachment.html

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

2006年08月12日 星期六 14:39

yi huang yi.codeplayer at gmail.com
Sat Aug 12 14:39:48 HKT 2006

>
> 我是在windown下使用python的,刚练习了一条break语句,但是出错了。
>
> 程序:
>
> while Ture:
>
>     s = raw_input('Enter something :')
>
>     if s == 'quit':
>
>         break
>
>     print 'Length of the string is ', len(s)
>
> print 'Done'
>
>
> 按F5之后,错误提示如下:
>
> >>> Exception in Tkinter callback
>
> Traceback (most recent call last):
>
>   File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
>
>     return self.func(*args)
>
>   File "C:\Python24\lib\idlelib\ScriptBinding.py", line 142, in
> run_module_event
>
>     code = self.checksyntax(filename)
>
>   File "C:\Python24\lib\idlelib\ScriptBinding.py", line 101, in
> checksyntax
>
>     return compile(source, filename, "exec")
>
> UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 31-32: ordinal not in range(128)
>
>
> 这是什么问题引起的,谢谢
>

首先根据错误消息, 你代码里应该不小心输入了一个非ascii字符
另外 True 不是 Ture,





-- 
http://codeplayer.blogbus.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060812/69c715d3/attachment.html

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

2006年08月12日 星期六 14:40

yi huang yi.codeplayer at gmail.com
Sat Aug 12 14:40:33 HKT 2006

Enter something :exit
Length of the string is  4
Enter something :quit
Done


:)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060812/63a7e0f1/attachment.htm

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

2006年08月12日 星期六 15:05

风向标 vaneoooo at gmail.com
Sat Aug 12 15:05:22 HKT 2006

UnicodeEncodeError



编码错误来的



2006/8/12, yi huang <yi.codeplayer at gmail.com>:
>
> Enter something :exit
> Length of the string is  4
> Enter something :quit
> Done
>
>
> :)
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060812/bfa8f445/attachment.html

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

2006年08月12日 星期六 15:10

jsz7758520 jsz7758520 at 163.com
Sat Aug 12 15:10:12 HKT 2006

怎么解决啊?
我又全部手工输入了一遍,还是错啊
前面是一不小心把true打成了ture了,现在改过来了,也一样的呢




jsz7758520
2006-08-12



发件人: 风向标
发送时间: 2006-08-12 15:05:57
收件人: python-chinese at lists.python.cn
抄送: 
主题: (瑞星提示-此邮件可能是垃圾邮件)Re: [python-chinese] 运行程序时出错,请教!

UnicodeEncodeError

编码错误来的


 
2006/8/12, yi huang <yi.codeplayer at gmail.com>: 
Enter something :exit
Length of the string is  4
Enter something :quit
Done


:)
 

_______________________________________________
python-chinese
Post: send python-chinese at lists.python.cn
Subscribe: send subscribe to python-chinese-request at lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060812/bffc6b9f/attachment.htm

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

2006年08月14日 星期一 11:09

HuangCong mail.huangcong at gmail.com
Mon Aug 14 11:09:01 HKT 2006

while True :
s = raw_input('Enter something :')
if s == 'quit':
break
print 'Length of the string is ', len(s)
print 'Done'


jsz7758520 写道:
> 怎么解决啊?
> 我又全部手工输入了一遍,还是错啊
> 前面是一不小心把true打成了ture 了,现在改过来了,也一样的呢
> ------------------------------------------------------------------------
> jsz7758520
> 2006-08-12
> ------------------------------------------------------------------------
> *发件人:* 风向标
> *发送时间:* 2006-08-12 15:05:57
> *收件人:* python-chinese at lists.python.cn
> *抄送:*
> *主题:* (瑞星提示-此邮件可能是垃圾邮件)Re: [python-chinese] 运行程序
> 时出错,请教!
> UnicodeEncodeError
>
> 编码错误来的
>
>
>
> 2006/8/12, yi huang <yi.codeplayer at gmail.com
> yi.codeplayer at gmail.com>>:
>
>     Enter something :exit
>     Length of the string is 4
>     Enter something :quit
>     Done
>
>
>     :)
>
>     _______________________________________________
>     python-chinese
>     Post: send python-chinese at lists.python.cn
>     python-chinese at lists.python.cn>
>     Subscribe: send subscribe to
>     python-chinese-request at lists.python.cn
>     python-chinese-request at lists.python.cn>
>     Unsubscribe: send unsubscribe to
>     python-chinese-request at lists.python.cn
>     python-chinese-request at lists.python.cn>
>     Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese


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

2006年08月14日 星期一 12:44

马踏飞燕 honeyday.mj at gmail.com
Mon Aug 14 12:44:25 HKT 2006

你在控制台输入中文了吧?

在 06-8-12,jsz7758520<jsz7758520 at 163.com> 写道:
>
> 我是在windown下使用python的,刚练习了一条break语句,但是出错了。
>
> 程序:
>
> while Ture:
>     s = raw_input('Enter something :')
>     if s == 'quit':
>         break
>     print 'Length of the string is ', len(s)
> print 'Done'
>
> 按F5之后,错误提示如下:
> >>> Exception in Tkinter callback
> Traceback (most recent call last):
>   File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in
> __call__
>     return self.func(*args)
>   File "C:\Python24\lib\idlelib\ScriptBinding.py", line
> 142, in run_module_event
>     code = self.checksyntax(filename)
>   File "C:\Python24\lib\idlelib\ScriptBinding.py", line
> 101, in checksyntax
>     return compile(source, filename, "exec")
> UnicodeEncodeError: 'ascii' codec can't encode characters in position 31-32:
> ordinal not in range(128)
>
>
> 这是什么问题引起的,谢谢
> ________________________________
>
> jsz7758520
> 2006-08-12
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to
> python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to
> python-chinese-request at lists.python.cn
> Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
>
>

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号