我做了一个有趣的项目,并创建了一个程序,当我第一次做它几个月前是无限的。我如何使它循环而不使它复制和粘贴自己一遍又一遍?你知道吗
if Type == "Admin":
Username = input("Username: ")
if Username == "Admin":
time.sleep(1)
Password = input("Password: ")
if Password == "Pass":
Help = input("Correct. Logged in. What would you like to do now? Type help for options. ")
if Help == "help":
print("Here's a list of things you can run.")
print("Paycheck, Status")
Command = input("Which command would you like to run? ")
if Command == "Paycheck":
print("You are currently being payed $0.")
time.sleep(5)
if Command == "Status":
print(
"2 members online currently. Servers open: Admin and User. Users online: "
"Admin, "
"User.")
time.sleep(5)
if Help == "Status":
print(
"2 members online currently. Servers open: Admin and User. Users online: "
"Admin, "
"User.")
time.sleep(5)
if Help == "Paycheck":
print("You are currently being payed $0.")
time.sleep(5)
在while循环中放入所有代码。比如:
while(1): #paste your code here
建议:
此循环没有结束(或直到ctrl-c):
如果要循环直到满足条件,可以执行以下操作:
使用while True可连续循环,使用while True中的break可中断循环(如果需要)。你知道吗
相关问题 更多 >
编程相关推荐