码迷,mamicode.com
首页 > 编程语言 > 详细

python 要点

时间:2017-04-09 19:19:04      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:targe   target   logs   imp   int   listening   pre   highlight   move   

要点整理

 

多线程
#coding=utf-8
import threading
from time import ctime,sleep


def music(func):
    for i in range(2):
        print ("I was listening to %s. %s" %(func,ctime()))
        sleep(1)

def move(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=move,args=(u‘阿凡达‘,))
threads.append(t2)

if __name__ == ‘__main__‘:
    for t in threads:
        t.setDaemon(True)
        t.start()

    print ("all over %s" %ctime())

  

python 要点

标签:targe   target   logs   imp   int   listening   pre   highlight   move   

原文地址:http://www.cnblogs.com/nidongde/p/6685908.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!