发布时间:2019-09-10 09:18:46编辑:auto阅读(2074)
前些天学到的线程,做下记录,以备后用:
程序如下:
import sys,time
import thread
def a():
for i in range(1,5):
time.sleep(0.5)
print "\nhello"
time.sleep(1)
def b():
for j in range(1,5):
time.sleep(1)
print "\nthen"
time.sleep(0.5)
thread.start_new_thread(a,())
thread.start_new_thread(b,())
线程1执行a(),线程2执行b(),为了看出效果,加入time.sleep()
实验验证:
但是我移植到pyqt内时,发现报错: Unhandled exception in thread started by <bound method MyForm.start2 of <__main__.MyForm object at 0x012C1348>>
google之,pyqt有自己的线程机制,好吧,继续努力。
上一篇: X3650M3\X3550M3用外置US
下一篇: 用Python实现CRUD功能REST服
51292
50744
41340
38151
32621
29520
28369
23242
23210
21532
1606°
2340°
1940°
1881°
2208°
1925°
2608°
4382°
4231°
3002°