当我运行我的Python代码我的Python刚刚关闭

时间:2016-12-21 08:00:47

标签: python

当我打开带有此代码的.py文件时,它会显示一小段时间然后消失。我如何解决这个问题,以便看到输出?

print "Hello welcome to Mcdonald's how may I help you"
print "Type 1 for food"
print "Type 2 for drinks"
user_input = input ("Type 3 for money")
if (user_input) == 1:
    print "We have Hamburgers, fries, and cancer"
    print "Type 1 for hamburgers"
    print "Type 2 for fries"
    user_input = input ("Type 3 cancer")
    if (user_input) == 1:
        print "That will cost you $1.25"
        print "Type 1 to pay"
        user_input = input ("Type 2 to steal")
        if (user_input) == 1:
            user_input = input ("Thank you for comming")
        elif (user_input) == 2:
           user_input = input ("HEY COME BACK AND PAY!") 
    elif (user_input) == 2:
        user_input = input ("Potato!")
    elif (user_input) == 3:
        user_input = input ("Sorry we are out of cancer")
if (user_input) == 2:
    print "We have Coke, and Pepsi"
    print "Type 1 for Coke"
    user_input = input ("Type 2 for Pepsi")
    if (user_input) == 1:
        user_input = input ("COKE SUCKS NO DRINKS FOR YOU!!!!!")
    elif (user_input) == 2: 
        print "Nice I LOVE Pepsi Coke sucks that will cost you $1.00"
        print "Type 1 to pay"
        user_input = input ("Type 2 to steal")
        if (user_input) == 2:
            user_input = input ("HEY COME BACK AND PAY!")
if (user_input) == 3:
    print "So heres the plan you take the register ill destract the others."
    print "Type 1 To call the cops"
    user_input = input ("Type 2 to do the plan")
    if (user_input) == 1:
        user_input = input ("You got $150 for calling the cops")
    elif (user_input) == 2:
        user_input = input ("You got $150 for doing the plan")
else:
    print "Sorry I did not get your order"

2 个答案:

答案 0 :(得分:0)

我假设您正在使用Windows。如果要查看输出,建议您在包含要执行的Python脚本的目录中打开命令提示符,然后尝试运行python <your script>.py

如果您在文件资源管理器中打开了目录(我想如果您双击该文件就会这样做),快捷方式是 Shift +右键单击文件浏览器并在此处选择&#34;打开命令窗口&#34;打开该目录中的提示。

答案 1 :(得分:-1)

打开cmd: 开始 - &gt; cmd(在“搜索程序和文件”中)并在此处运行脚本。