import threading
def foo():
with open(r'./result.log','wb') as f:
f.write('=some logs here ==')
t = threading.Thread(foo)
t.start()
当然你也可以用高级方法,参考这,https://docs.python.org/2/library/multiprocessing.html?highlight=apply_async
import threading
def foo():
with open(r'./result.log','wb') as f:
f.write('=some logs here ==')
t = threading.Thread(foo)
t.start()
当然你也可以用高级方法,参考这,https://docs.python.org/2/library/multiprocessing.html?highlight=apply_async
转载于:https://www.cnblogs.com/Tommy-Yu/p/4026725.html