假设我有这个脚本:
import time
def menu():
n = raw_input("What do you want the script to do: ").lower()
if n == "run":
r = run()
elif n == "exit":
exit()
else:
print("Unknown command")
print("Result: " + r)
def run():
t = 0
while t < 60:
print("This script is doing some stuff")
time.sleep(1)
t = t + 1
return "Some kind of result"
if __name__ == '__main__':
print("Starting the most useless script ever")
while True:
menu()
如何在打印时停止脚本“此脚本正在执行某些操作”并返回Menu()?我不想完全退出程序,只想回到菜单。在
你要做的就是创建一个函数库。在
函数
a
必须有两个位置参数关于这件事呢:
相关问题 更多 >
编程相关推荐