我正在尝试创建一个程序;但是,即使输入了“y”或“yes”,代码仍然会进入“n”/“no”循环。有什么建议吗?在
no = input("How many messages?")
intNo = int(no)
msgno = input("2 different msgs? [y/n]:")
message = input("Message:")
message2 = input("Message 2:")
run = True
pyautogui.click(x=980, y=805, button='left')
while run == True:
if msgno.lower() == "n" or "no":
pyautogui.typewrite(message, interval=0.00001)
pyautogui.press('enter')
intNo = intNo - 1
if intNo <= 0:
run = False
elif msgno.lower() == "y" or "yes":
no = no / 2
pyautogui.typewrite(message, interval=0.00001)
pyautogui.press('enter')
pyautogui.typewrite(message2, interval=0.00001)
pyautogui.press('enter')
intNo = intNo - 1
if intNo <= 0:
run = False
必须在每个If语句中添加两个条件语句。像这样:
if msgo.lower() == 'yes' or msgo.lower() == 'y'
如果只存在一个变量或一个值,它将默认为True,因此“no”默认为True并进入代码块。在相关问题 更多 >
编程相关推荐