我需要为每个线程指定变量的值。
def login():
driver.find_element(By.ID, 'login.email').send_keys(mail)
t1 = threading.Thread(target=login, mail="")
t2 = threading.Thread(target=login, mail="")
t3 = threading.Thread(target=login, mail="")
t4 = threading.Thread(target=login, mail="")
t5 = threading.Thread(target=login, mail="")
t6 = threading.Thread(target=login, mail="")
t7 = threading.Thread(target=login, mail="")
t8 = threading.Thread(target=login, mail="")
t9 = threading.Thread(target=login, mail="")
t10 = threading.Thread(target=login, mail="")
def login(x):
driver.find_element(By.ID, 'login.email').send_keys(x)
thread_list = []
for x in range(10):
thread = threading.Thread(target=login, args=(x))
thread_list.append(thread)
for thread in thread_list:
thread.start()
thread.join()
你可以for循环,然后使用一个参数线程。