[未完成]python后台线程

  |   0 评论   |   0 浏览

背景

import time
from hashlib import md5
from threading import Thread

def pmd(md):
    time.sleep(3) #使用sleep使得该线程比主线程晚结束
    print("backend recording:",md)


def giveures(s):
    md = md5(s.encode('utf-8'))
    res = md.digest()
    t = Thread(target=pmd,args=(s,))
    t.setDaemon(True)
    t.start()
    return res

s = 'chrisyang'
res = giveures(s)
print(res)
exit()

参考