问一下Python中关于threading的一些问题
用Python 2.7版本写了一个简单有关线程的程序,代码如下:import threadingfrom time import ctime,sleep
def music(func):
for i in range(2):
print 'I was listening to %s.%s'%(func,ctime())
sleep(1)
def movie(func):
for i in range(2):
print 'I was at the %s.%s'%(func,ctime())
sleep(5)
threads=[]
t1=threading.Thread(target=music,args=(u'爱情买卖',))
threads.append(t1)
t2=threading.Thread(target=movie,args=(u'阿凡达',))
threads.append(t2)
if __name__=='__main__':
for t in threads:
t.setDaemon(True)
t.start()
t.join()
print 'all over %s'%ctime()但是执行的时候出错了,提示:Runtime Error!
希望大大们能帮忙看看原因在哪?找不到哪里出错了。先谢谢大家! 应该没什么问题阿 我这边linux 下 可以哦 之前用的Python自带的IDEL,每次运行时都会报那个RunError的错误。但是我换了一个编辑器,用的Sublime text 2,运行了一下,居然跑通了。
虽然问题解决了,但是不知道为什么啊,后郁闷。谢谢你的解答。
Linux_manne 发表于 2014-11-20 13:53 static/image/common/back.gif
应该没什么问题阿 我这边linux 下 可以哦
页:
[1]