【发布时间】:2021-02-27 22:50:16
【问题描述】:
如何告诉我的代码不要结束并重新开始?
来自第一个try:
运行 = 真 运行时:
f = open('list.txt', 'r', encoding='utf-8').readlines()
for word in f:
if word == "\n":
continue
driver.find_element_by_xpath(Newtweet_button).click()
sleep(0.5)
driver.find_element_by_xpath(message_paste).send_keys(word)
try:
driver.find_element_by_xpath(post_tweet_xpatch).click()
sleep(1)
except (ElementClickInterceptedException):
driver.find_element_by_xpath(cross_button).click()
except (NoSuchElementException):
print("tweet not send")
driver.find_element_by_xpath(cross_button).click()
sleep(4)
else:
driver.find_element_by_xpath(close_button2).click()
sleep(4)
f.close()
【问题讨论】:
-
您好,fahad,看起来您添加的代码没有缩进,如果您像文件中显示的那样添加缩进会更容易回答。
标签: python selenium loops webdriver