要点整理

 

多线程
#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())

  

相关文章:

  • 2022-12-23
  • 2021-10-16
  • 2021-07-10
  • 2021-06-22
  • 2021-10-21
  • 2021-12-18
  • 2022-12-23
  • 2021-07-22
猜你喜欢
  • 2021-06-07
  • 2022-01-18
  • 2021-11-17
  • 2021-12-11
相关资源
相似解决方案