我是python的初学者,当我尝试创建一个函数来登录和注册时,它总是给我一个错误“NameError:name'Login'未定义”和/或NameError:name'register'未定义,如果你看到我可以改进的地方,请告诉我
print('Banking app')
start = input('Login or Register?')
# if the user wants to log in
if start == "Login":
Login()
def Login(self, start):
pass
userName = input("Enter your username: ")
passWord = input("Enter your password: ")
#checking for the account
with open('Users.txt') as f:
if userName and passWord in f.read():
print('UserFound')
accountFound = True
else:
print("Account not found ")
accountFound = False
if start == "Register":
Register()
#if user wants to make a account
def Register(self, start):
pass
newUser = input("Enter your desired user: ")
newPass = input("Enter your desired password: ")
f = open('Users.txt', 'a')
f.write(newUser)
f.write(newPass)
f.close()
在调用Login()函数之前,应该先定义它,对于Register函数也是如此
例如:
相关问题 更多 >
编程相关推荐