我的简单python编程没有正确执行一个函数

时间:2015-12-09 14:44:57

标签: python function python-2.7

好的,所以我对python很新,而且出于某种原因,我似乎在弄乱这里的东西。有帮助吗?每当我运行程序时,它似乎默认为第一个函数。

import time
main_menu = 5

def option1():
    print time.localtime()
    main_menu = 5
    main()
def option2():
    print 'You selected Option 2'
    main_menu = 5
    main()
def option3():
    print 'You selected Option 3'
    main_menu = 5
    main()

def main():
    main_menu = 5
    while main_menu==5:
        print '[1] Select option 1'
        print '[2] Select option 2'
        print '[3] Select option 3'
        mainInput = raw_input("Welcome! Type a selection\n> ")
        if mainInput == "1" or "one":
            main_menu = 6
            option1()
        if mainInput == "2" or "two":
            main_menu = 6
            option2()
        if mainInput == "3" or "three":
            main_menu = 6
            option3()

main()

0 个答案:

没有答案