本来处理数据需要用2-3天,加入多线程用了7个小时,觉得多线程挺有用,记录下。
import threading
n_SeriesIds = [SeriesIds[i:i+42] for i in range(0, len(SeriesIds), 42)]
def seriesid_handle(seriesids):
xxxxxx
if __name__ == '__main__':
threads = []
for i in range(len(n_SeriesIds)):
thread = threading.Thread(target=seriesid_handle, args=(n_SeriesIds[i],))
threads.append(thread)
for thread in threads:
thread.start()
for thread in threads:
thread.join()
print("DONE!")