需要完善
#coding=utf-8
import threadingfrom time import ctime,sleep
def music(func):
for i in range(10):
# print("I was listening to %s. %s" %(func,ctime()))
# open("./a.txt","a",encoding="UTF-8").write("a")
print("a",end='-')
sleep(0.5)
def move(func):
for i in range(5):
# open("./b.txt","a",encoding="UTF-8").write("b")
print("b",end='-')
sleep(0.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()
for t in threads:
t.join()
print("all over")