当前位置: 动力学知识库 > 问答 > 编程问答 >

python - Can I go back to a specific line when an exception occurs?

问题描述:

Is there any specific command or logic that I can go back to a specific line in code and iterate from that point?

Below is my code example:

self.driver.implicitly_wait(0.3)

while True:

try:

models = [

('%s' % o.get_attribute('text'), '%s' % parse.unquote(o.get_attribute('href')))

for o

in self.driver.find_elements_by_css_selector("#layer_group ul.list li a")

if o.text != '전체'

]

except (StaleElementReferenceException, NoSuchElementException):

continue

break

When the WebDriverException occurs, I would like to go back to the first line of the sample code. Is there any specific command or logic for that except for the way that puts "self.driver.implicitly_wait(0.3)" into the while loop?

分享给朋友:
您可能感兴趣的文章:
随机阅读: