【发布时间】:2016-03-10 08:18:29
【问题描述】:
我是 Python 3.5.1 的学习者和新用户 我正在尝试制定一个简单的反馈程序,仅用于创建存储在列表中的帐户以及登录它们。如果用户成功登录或密码错误,我应该向用户提供反馈。我打算使用模块功能,但我想保持简单并尽可能避免使用它。这是我已经完成的代码,但它不起作用。
user={}
import lib`
while 1:
print("Welcome to the login portal.")
print("Do you have an existing account? y/n")
answer=input()
if answer==("y").lower():
login()
if answer==("n").lower():
create()
if answer==("q").lower():
quit()
else:
tryagain()
**如在lib文件中,代码为:*
def tryagain():
while 2:
print("Please try again or press q to quit.")
print("Do you have an existing account? y/n")
def create():
print("Please create a username and password.")
print("Username: ")
createun=input()
print("Password: ")
createps=input()
print("Account creation successful. Please login to continue.")
login()
def login():
print("Please enter your username: ")
loginun=input()
if createun==loginun:
print("Please enter your password: ")
loginps=input()
if createps==loginps:
print("Account validation successful.")
elif createps!=loginps:
print("Password incorrect. Please try again.")
else:
print("Login Failed!")
if __name__== "__main__":
print("Module successfully loaded.")
input("Press the enter key to exit.")
谁能帮帮我?
【问题讨论】:
标签: python-3.x