【发布时间】:2018-12-19 08:48:38
【问题描述】:
我的 logins() 子例程在找到登录名并验证密码后将继续执行 else 和 elif 部分。我似乎无法理解它为什么这样做,但确实阻碍了我的进步。 enter image description here
def login ():
Username_Input = input("Please enter your username : ")
logins = open("logins.csv","r")
List_Information = list(csv.reader(logins))
for x in List_Information:# loops through all lists
if x[0] != Username_Input :
print("Username not found please register ")
register ()
else:
Password_Input = input("Username found please enter your password : ")
for x in List_Information:
if x[1] == Password_Input :
print("Loged in lets get this game going. ")
game()
else :
print("nope sorry password not found lets go back to the menu : ")
Menu()
【问题讨论】:
-
请将您的程序输出粘贴到问题中。没有文字图片。
-
这个帖子可能会帮助你stackoverflow.com/questions/21560739/…
-
“将继续携带 ou”:您在
for ...循环内完成全部。如果你想结束循环,你必须使用break。阅读break
标签: python if-statement subroutine