Python的各种异常

1.SyntaxError: Non-ASCII character '\xe5' in file D:\eclipse\workspace\MyPython\src\pack1\hello.py on line 4, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

原来是 #coding=utf-8 这句没有放在首行。


2.raceback (most recent call last):
  File "D:\eclipse\workspace\MyPython\src\pack1\hello.py", line 90, in <module>
    print("i="+i)

TypeError: cannot concatenate 'str' and 'int' objects

翻译为“类型错误:不能将‘str’和‘int’对象联系起来”。

类型转换错误,如果需要拼接str和int,需要类型转换。


3.TypeError: 'str' object is not callable

翻译为“错误类型:‘str’对象不能被调用”。

str()为系统自带函数,检查代码中是否有自定义的str变量名。


4.“Unhandled exception in thread started by 
        sys.excepthook is missing

        lost sys.stderr”

启动线程后,只有当子线程返回结果后主线程才可正常结束,上述问题就在于主线程早于子线程结束,因而可以在程序最后加一句“time.sleep(30)”,确保子线程先结束。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值