好的,我正在编写一个简单的登录系统,这是代码
import time
for counter in range(5):
username=str(raw_input("Please enter your username"))
password=str(raw_input("Please enter your password"))
if username =="bros10":
print "",username,"entered"
time.sleep(4)
print "You got the username right"
if password =="brosbros10":
print "You got the password right"
print "Welcome to the system"
break
else:
print "Try again"
当我运行它时会发生什么,它将打印此位打印"",用户名,"输入"输入密码后 任何帮助表示赞赏
答案 0 :(得分:1)
移动它:
print "",username,"entered"
在此之前:
password=str(raw_input("Please enter your password"))
现在你的程序将要求输入用户名,重复输入的用户名(如果他们输入bros10
,告诉用户他们说得对,)然后要求输入密码,然后睡4秒。
或者,您可以将password=
行放在此前一行
if password =="brosbros10":
如果您希望在等待4秒并重复用户输入后要求输入密码。
答案 1 :(得分:0)
如果我理解你是正确的,那么在输入密码之前你想要print "",username,"entered"
。那应该是:
import time
for counter in range(5):
username=str(raw_input("Please enter your username"))
print "",username,"entered"
if username == "bros10":
print "You got the username right"
password=str(raw_input("Please enter your password"))
time.sleep(4)
if password =="brosbros10":
print "You got the password right"
print "Welcome to the system"
break
print "Try again"