''' 線程鎖 ''' import threading import time lock = threading.Lock() lock.acquire() #獲取鎖 lock.release() #釋放鎖 #with lock: #自動開啓,關閉鎖 with lock: time.sleep(3) #相似 # with open("1.txt","w") as f: # f.close() #kafka go開發