1 回答
TA貢獻1789條經驗 獲得超10個贊
最好的辦法是并行。我知道一種方法,但可能有更有效的方法來做到這一點。
import threading
from sys.stdout import flush
from sys import argv
from selenium import webdriver
website_loaded = False
def loading():
while not website_loaded:
print("Loading.\r")
flush()
print("Loading..\r")
flush()
print("Loading...\r")
flush()
driver = mydriverslocation
website = argv[1]
# Start the loading thread
# Expected method to run, and arguments.
loading_thread = threading.Thread(loading, ())
loading_thread.start()
driver.get(website)
# And any other code while loading
# This will pass to the thread
website_loaded = True
添加回答
舉報
