達到條件后如何呼叫該函式。我做了一些函式,但函式只呼叫一次。除非我再次運行編碼,否則下次無法使用。
如果我只有一個功能,它可以在達到一定條件時呼叫。
def once():
ret = False
while True:
if driver.find_element(By.ID, "ONCE"):
driver.refresh()
ret = True
return ret
once()
def twice():
ret = False
element = driver.find_element(By.ID, "Twice")
while True:
if driver.find_element(By.ID, "Twice"):
elmenet.click()
ret = True
return ret
twice()
我希望該函式在達到條件時可以自動呼叫。
但我不知道該怎么做。
例如,
當我達到條件時,def 將自動呼叫。
uj5u.com熱心網友回復:
您可以使用
while回圈,而回圈將繼續運行,直到條件為真,當條件為假時將停止
x=10
def PRINT():
print(str(x) ' is greater than 0')
while x > 0 :
PRINT()
x=x-1
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/527562.html
標籤:Python功能硒
