def score_program_100self try # 循环打分100分值 while True if not selfrunning break if selfpaused continue
修改后的代码如下:
def score_program_100(self):
try:
# 循环打分100分值
while True:
if not self.running:
break
if self.paused:
continue
blank_message = self.browser.find_elements(By.CLASS_NAME, 'blank-message')
if blank_message:
self.update_text_box('当前题目没有内容,不进行打分')
time.sleep(2.5)
continue
score_box = self.browser.find_element(By.CLASS_NAME, 'score-box')
score_input = score_box.find_element(By.TAG_NAME, 'input')
score_input.clear()
score = random.randint(94, 99)
score_input.send_keys(str(score))
time.sleep(1.5)
submit_button = self.browser.find_element(By.CLASS_NAME, 'nav-text')
submit_button.click()
time.sleep(2.5)
self.update_text_box(f"本次题目分值为:{score}")
if '已到最后' in self.browser.page_source:
self.update_running_label('已到最后,请手动保存后重新开始!')
break
else:
self.update_running_label('百分制打分中...')
except Exception as e:
print(e)
self.update_running_label('百分制打分失败,请重试'
原文地址: http://www.cveoy.top/t/topic/htj0 著作权归作者所有。请勿转载和采集!