如何按顺序使用我的定义?

时间:2016-11-02 09:33:19

标签: python python-2.7

我想知道如何将我的定义放在一个订单中,所以当用户想要重新启动程序时,它会从它停止的地方开始。

我的例子如下:

import time

def problems():
    user = raw_input ("Hello there! would you like to run a troubleshoot to try and resolve the issue with your phone? (Y/N)")
    if user == "Y":
        print "running trouble shooting program..."
        time.sleep(1)
        wet()
    if user == "N":
        print "closing the program..."
        time.sleep(1)
        quit()
    else:
        print "input not recognised try again!"
        time.sleep(1)
        problems()

def wet():
    wet = raw_input ("Have you got the phone wet (Y/N)")
    if wet == "Y":
        print "Try putting the phone in some rice or cous cous for 24 hours"
        time.sleep(1)
        resolved()
    if wet == "N":
        resolved()
        print "Ouputting next question..."
        time.sleep(1)
        screen()
    else:
        print "input not recognised try again!"
        time.sleep()
        wet()

def virus():
     wet = raw_input ("Has the phone got a virus? (Y/N)")
    if wet == "Y":
        print "Do a factory reset of the phone."
        time.sleep(1)
        resolved()
    if wet == "N":
        resolved()
        print "Ouputting next question..."
        time.sleep(1)
        virus()
    else:
        print "input not recognised try again!"
        time.sleep()
        wet()


def resolved():
    yes = raw_input ("Would you like to continue?(Y/N)")
    if yes == "N":
        print "Thankyou for using this trouble shoot, closing the program..."
        time.sleep(1)
        quit()
    if yes == "Y":
        print "Restarting troubleshoot programming..."
        time.sleep(1)
    else:
        print "input not recognised try again!"
        resolved()

problems()

我希望使用此代码实现的目的是将其重置为用户完成回答他/她之前问题的位置。例如,如果用户收到他们的电话被弄湿的答案,那么它将运行定义,允许他们选择离开或继续。如果他们想继续下去,那么就会进入下一个定义。请记住我计划添加更多定义,因此我需要一个可以在用户输入后继续的一般订单。

0 个答案:

没有答案