我不明白为什么它不会开始,因为昨天程序运行得非常顺利。我已经尝试了所有重新启动我的计算机,重新安装python和调试没有任何工作可能有人请帮助我也尝试使用部分代码仍然没有工作是代码还是python?
谢谢。
import os
import time
def main():
print("Search: Registration | Login")
print("Note: Must Registrate first to continue")
time.sleep(2)
print("Welcome To CityRP Gaming!")
search = input("Search.... ")
if search == 'registration':
reg()
if search == 'login':
login()
#Must Register to continue
def reg():
print("Display Name")
reg_user = input()
print("Password")
reg_pass = input()
time.sleep(1)
print("Registration Successful!")
main()
#Must Login to continue
def loging():
print("Enter Username: ")
username = input()
print("Enter Password: ")
password = input()
if username == 'reg_user' and password == 'reg_pass':
time.sleep(1)
print("Login Successful!")
logged()
else:
print("Try Again!")
loging()
#Main logged in interface
def logged():
time.sleep(1)
print("Welcome To CityRP Gaming")
time.sleep(3)
print("What would you like to do?")
time.sleep(3)
print("Friends, Rules, Search, Register, Exit")
cmdlist = input()
if cmdlist == 'Friends':
friends = input("Do you want friends?")
logged()
elif cmdlist == 'Rules':
print('''\nRules:
\n-No racism,
\n-No mini-hitlers''')
logged()
elif cdmlist == 'Search':
main()
elif cdmlist == 'Register':
reg()
答案 0 :(得分:0)
您需要先调用要执行的功能。
例如:在程序结束时调用main()
- 如果您希望执行main函数。
由于python不支持forward referencing,您可能希望将main函数放在程序的末尾。
这是一个有效的代码
import os
import time
#Must Register to continue
def reg():
print("Display Name")
reg_user = input()
print("Password")
reg_pass = input()
time.sleep(1)
print("Registration Successful!")
main()
#Must Login to continue
def login():
print("Enter Username: ")
username = input()
print("Enter Password: ")
password = input()
if username == 'reg_user' and password == 'reg_pass':
time.sleep(1)
print("Login Successful!")
logged()
else:
print("Try Again!")
login()
#Main logged in interface
def logged():
time.sleep(1)
print("Welcome To CityRP Gaming")
time.sleep(3)
print("What would you like to do?")
time.sleep(3)
print("Friends, Rules, Search, Register, Exit")
cmdlist = input()
if cmdlist == 'Friends':
friends = input("Do you want friends?")
logged()
elif cmdlist == 'Rules':
print('''\nRules:
\n-No racism,
\n-No mini-hitlers''')
logged()
elif cdmlist == 'Search':
main()
elif cdmlist == 'Register':
reg()
def main():
print("Search: Registration | Login")
print("Note: Must Registrate first to continue")
time.sleep(2)
print("Welcome To CityRP Gaming!")
search = input("Search.... ")
if search == 'registration':
reg()
if search == 'login':
login()
if __name__=="__main__":
main()
答案 1 :(得分:0)
在CityRP Gaming准备推出之前,你还有很长的路要走。
这是您的代码,其中包含一些拼写错误,用户和密码存储在global
变量中(以帮助您前进)。一旦开始将它们存储在文件/数据库等中,您就不会需要它们。
import os
import time
def main():
print("Search: Registration | Login")
print("Note: Must Registrate first to continue")
time.sleep(2)
print("Welcome To CityRP Gaming!")
search = input("Search.... ")
if search == 'registration':
reg()
if search == 'login':
login()
#Must Register to continue
def reg():
global reg_user, reg_pass
print("Display Name")
reg_user = input()
print("Password")
reg_pass = input()
time.sleep(1)
print("Registration Successful!")
main()
#Must Login to continue
def login():
print("Enter Username: ")
username = input()
print("Enter Password: ")
password = input()
if username == reg_user and password == reg_pass:
time.sleep(1)
print("Login Successful!")
logged()
else:
print("Try Again!")
login()
#Main logged in interface
def logged():
time.sleep(1)
print("Welcome To CityRP Gaming")
time.sleep(3)
print("What would you like to do?")
time.sleep(3)
print("Friends, Rules, Search, Register, Exit")
cmdlist = input()
if cmdlist == 'Friends':
friends = input("Do you want friends?")
logged()
elif cmdlist == 'Rules':
print('''\nRules:
\n-No racism,
\n-No mini-hitlers''')
logged()
elif cmdlist == 'Search':
main()
elif cmdlist == 'Register':
reg()
if __name__=="__main__":
main()
P.S。不确定registrate
是一个真实的词:)