因此,我尝试使用 Python3 在终端中编写登录对话,但由于某种原因,此代码:def start(): login_signin_Confirmation = input("Welcome! Do you wish to log-in to your account or sign up to this platform? \n") if login_signin_Confirmation == "login": login() else: signup() start()def login(): login_username = input("Great! start by typing in your username.") if login_username in users: print("Welcome Back, {login_username}")login()提示我此错误消息:Welcome! Do you wish to log-in to your account or sign up to this platform? loginTraceback (most recent call last): File "login.py", line 22, in <module> start() File "login.py", line 19, in start login()NameError: name 'login' is not defined刚开始一些我不太确定我做错了什么,而且我找不到有同样问题的人......
1 回答
天涯尽头无女友
TA贡献1831条经验 获得超9个赞
正如其他人指出的,您需要首先定义,然后调用函数:
# imports first
# now definitions of functions
def start():
login_signin_Confirmation = input("Welcome! Do you wish to log-in to your account or sign up to this platform? \n")
if login_signin_Confirmation == "login":
login()
else:
signup()
def signup():
pass
def login():
login_username = input("Great! start by typing in your username.")
if login_username in users:
print("Welcome Back, {login_username}")
# main
def main():
start()
# guard multiprocess context
if __name__ == '__main__':
main()
添加回答
举报
0/150
提交
取消