好吧,我的代码可以正常工作,但是当我输入“否”时,如果我想重试输入密码,它就不起作用了;它只是进入输入密码行(第 20 行)。我已经尝试了多种方法来解决这个问题,但我根本做不到。
import time
import os
print ("Hello world.")
time.sleep(1)
print ("Waiting 5 seconds.")
time.sleep(5)
print ("You have waited 10 seconds.")
print ("Executing Chrome.")
time.sleep(1)
print ("Execution failed!")
password = input("Enter the execution password: ")
if password == 'password1234':
os.system ('C:\\Users\\Harry\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe')
else:
print ("Wrong password!")
time.sleep(1)
passretry = input("Do you want to try again? ")
if passretry == 'yes' or 'Yes':
passretry1 = input("Enter password: ")
if passretry1 == 'password1234':
os.system ('C:\\Users\\Harry\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe')
elif passretry == 'no' or 'No':
print ("Closing...")
time.sleep(1)
else:
print ("Wrong password.")
time.sleep(.5)
print ("Retry limit exceeded, closing.")
time.sleep(1)