我正在寻找一种方法 - 在您选择了您想要查看的内容(main_screen_choice)之后 - 能够选择其他内容而无需重新启动程序。这里是我的代码Python刷新登录系统代码
users = []
victims = ['John Smith', 'Karen Jones', 'Kevin Tomlinson']
print ('>>>>> RauCo. Protection Corp. <<<<<')
user = input('Username: ')
def storeUser():
users.append(user)
def check():
if user == 'Cabbage':
storeUser()
print ('Welcome back, Master...')
else:
print ('INTRUDER')
exit()
check()
main_screen_choice = input('What do you want to do? \nVictims, To Do,
Exit\n(Case Sensitive!): ')
def checkMainChoice():
if main_screen_choice == 'Victims':
print (victims)
elif main_screen_choice == 'To Do':
print ('Have a shower - you stink!')
elif main_screen_choice == 'Exit':
exit()
else:
print ('Error: Not a valid option, please run program again')
checkMainChoice()
再次调用'input'? –
了解循环如何工作,例如https://www.learnpython.org/en/Loops并将你的输入封装到一个循环中。 – Milo