问题描述
让我们说,looper == 1; calc()正在运行,然后如何通过键入home或timer或help摆脱它?我可以逃避一个循环并转到另一个循环吗?
import time
looper = 0
def timer():
timer = int(input())
while timer > 0:
time.sleep(1)
print(timer)
timer = timer - 1
def calc():
print(eval(input()))
def help():
print("Type ~calc~ to open calculator")
print("Type ~timer~ to open timer")
user = input()
if user == "home":
print("Back to home.")
print("Type ~help~ to show list of commands")
looper = 0
elif user == "calc":
print("Opened calculator")
looper = 1
elif user == "timer":
print("Opened timer")
looper = 2
elif user == "help":
looper = 3
else:
print("UnkNown command!")
looper = 4
while looper == 1:
calc()
while looper == 2:
timer()
while looper == 3:
help()
如果我键入calc,我可以在一行上添加数字
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)