蟒蛇。在另一个程序中编程

时间:2017-08-07 22:07:52

标签: python python-2.7

我试图使用导入功能在另一个程序中运行程序。然而,它运行,它绕过我的功能,只运行其他程序。

import ex35
def beginning():
    print "you have three door choices.  door a,b,c"
    door=raw_input("> ")
    if door=="c":
        ex35.start(door)
    elif door=="a":
        print "do i have to put stuff down?"
    else:
        print "i finally got it to work"

beginning()

if __name__ == "__main__":
   # stuff only to run when not called via 'import' here
   main()

1 个答案:

答案 0 :(得分:0)

好吧,我想通了。有点儿。整个if_name _ == “main :没有用,所以我想出了这个

def start():     打印“你有三个门选择。门a,b,c”     door = raw_input(“>”)

如果用户输入c则应运行ex 35 function start

if door=="c":
     import ex35
elif door=="a":
    import ex1
else:
    import ex2

开始()