Python 2.7 为什么可以';我不能得到一个退出命令来工作吗
您好,我是Python2.7.3的新手,我正在尝试在两个if语句之后编写一个自动退出子句Python 2.7 为什么可以';我不能得到一个退出命令来工作吗,python-2.7,Python 2.7,您好,我是Python2.7.3的新手,我正在尝试在两个if语句之后编写一个自动退出子句 import os password = "Anhur" attempt = 0 while (password != "Anhur") and (attempt <= 3): password = raw_input("Password: ") attempt = attempt + 1 if attempt == 3: print ("You have u
import os
password = "Anhur"
attempt = 0
while (password != "Anhur") and (attempt <= 3):
password = raw_input("Password: ")
attempt = attempt + 1
if attempt == 3:
print ("You have used all your attempts, the system will now close..")
print (" The shifting sands have ended you.")
break
if (password == "Anhur"):
print ("You conquered the sands")
os.exit(1)
导入操作系统
password=“Anhur”
尝试=0
而(密码!=“Anhur”)和(尝试只需使用exit()
导入操作系统
password=“”
尝试=0
而(密码!=“Anhur”)和(尝试Hi,
有用的答案。不过,初始代码有缺陷且毫无用处。请尝试以下代码:
import os
password = ""
attempts = 0
found = False
while (attempts <= 2):
password = raw_input("Password: ")
attempts = attempts + 1
if (password == "Anhur") :
found = True
break
if found:
print ("You conquered the sands")
exit(0)
else:
print ("You have used all of your attempts, the system will now close..")
print (" The shifting sands have ended you.")
exit(1)
导入操作系统
password=“”
尝试次数=0
发现=错误
而
import os
password = ""
attempts = 0
found = False
while (attempts <= 2):
password = raw_input("Password: ")
attempts = attempts + 1
if (password == "Anhur") :
found = True
break
if found:
print ("You conquered the sands")
exit(0)
else:
print ("You have used all of your attempts, the system will now close..")
print (" The shifting sands have ended you.")
exit(1)