python错误Unhandled exception in thread started by Error in sys.excepthook
来源:互联网 发布:读卡器java二次开发 编辑:程序博客网 时间:2024/06/03 22:55
import timeimport threaddef timer(no, interval): cnt = 0 while cnt<10: print 'Thread:(%d) Time:%s/n'%(no, time.ctime()) time.sleep(interval) cnt+=1 thread.exit_thread() def test(): #Use thread.start_new_thread() to create 2 new threads thread.start_new_thread(timer, (1,1)) thread.start_new_thread(timer, (2,2)) if __name__=='__main__': test()
出现错误
Unhandled exception in thread started by
Error in sys.excepthook:
Original exception was:
解决方法:将主函数改为
<pre>if __name__=='__main__': test()time.sleep(3)
至于为什么要睡几秒,不是很清楚
网上的说法是不建议使用thread,应尽量使用threading.Thread类
- python错误Unhandled exception in thread started by Error in sys.excepthook
- Python报错: Unhandled exception in thread started by Error in sys.excepthook
- 解决pycharm运行多线程程序报错"Unhandled exception in thread started by sys.excepthook is missing"
- Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x000001DB1D7557
- nhandled exception in thread started by <function wrapper at 0x035BA3F0>
- Unhandled exception in XX.exe:oxc0000005:access violation 错误调试
- 奇怪的 unhandled exception in 0xc0000005 *.exe:、错误
- 运行DBCA Exception in thread "main"错误
- Scrapy [twisted] CRITICAL: Unhandled error in Deferred:错误
- Scrapy Unhandled error in Deferred
- Python scrapy run with Unhandled error in Deferred解决方案
- Python scrapy run with Unhandled error in Deferred解决方案
- 【OSG运行错误】Unhandled exception at 0x7709B872 in XXXX.exe:Microsoft C++exception:std::bad_alloc
- Improved Unhandled Exception behavior in .net 2.0
- unhandled exception in:0xC0000005:Acess Violation
- Exception in thread "main" java.lang.ArithmeticException: / by zero
- Exception in thread main java.lang.Error Unresolved compilation problem
- Exception in thread "main" java.lang.Error: Unresolved compilation problem
- hdu 1509 Windows Message Queue 优先队列
- linux C函数之stat函数
- 横竖屏切换时候Activity的生命周期
- 判断浮点数是否等于0
- Spring动态切换多数据源解决方案
- python错误Unhandled exception in thread started by Error in sys.excepthook
- redis--5--Redis 的安装配置介绍
- hdu 4731 Minimum palindrome(暴力打表找规律)
- 克里称美俄同意联合国草案可含对叙动武内容
- 2013成都网络赛 两个简单题
- Android 源码下载注意事项
- 短路与&&和&
- 2014阿里巴巴笔试题
- 你是否用对了方式——女人要的是追求不是勾搭、纠缠、泡(