2016-12-21 30 views
0

當我打開我的.py文件與此代碼中,它顯示了一個簡短的第二次,然後消失。我如何解決這個問題,以便我可以看到輸出結果?運行我的Python代碼我的Python只是關閉

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" 
+1

*「巨蟒只是關閉」 * - 您是否使用的窗口?並在Windows資源管理器中雙擊該文件?如果是的話,那麼你將不得不學習如何使用命令行或添加什麼東西在你的程序結束時暫停執行(例如:一個'輸入()') – UnholySheep

+1

也請(學會)正確地格式化你的代碼,有創建 – UnholySheep

+0

此外,如果你想在這裏粘貼代碼的問題時做的大部分是自動選擇,請用「輸入代碼」按鈕做到這一點。現在它是不可讀的。 – Moberg

回答

0

我假設你使用的是Windows。如果你想看到的輸出,我建議你在包含要執行,然後嘗試運行python <your script>.py的Python腳本的目錄中打開一個命令提示符。

如果你有一個文件瀏覽器打開的目錄(我猜你做,如果你雙擊該文件),一個快捷鍵是 +文件資源管理器中單擊鼠標右鍵,選擇「在此打開命令窗口「以打開該目錄中的提示。

-1

打開CMD: 開始 - > CMD(在「搜索程序和文件」),並運行在這個腳本。