2015-04-23 39 views
-1

進出口完成,它說,過程與退出代碼0結束沒有我restaurant_list或任何後Python腳本不調用主要功能,說過程中使用pycharm退出代碼爲0

def main(): 
    # Make a list of resturaunts the resturaunteur could go to 
    restaurants_list = ['Mcdonalds', 'BurgerKing', 'Wendys', 'PaneraBread'] 
    print(restaurants_list) 
    # Remove expensive resturaunt from the list 
    print('Here are the restaurants in the list') 
    print(restaurants_list) 
    # Get the restaurant to change 
    restaurant = input('Which restaurant to remove?') 
    # Remove the restauraunt 
    restaurants_list.remove(restaurant) 
    #Display the list 
    print('Here is the revised list') 
    print(restaurants_list) 
    if __name__ == "__main__": 
    main() 
+2

你有沒有**叫**'main' ?! – jonrsharpe

+0

如何調用main? –

+0

當我打電話給main時,仍然沒有工作() –

回答

1

您需要添加在以下文件結尾:

if __name__ == "__main__": 
    main() 

...調用你的主函數。還要確保你的PyCharm被配置爲運行正確的腳本。

+0

我怎麼配置它來運行正確的腳本發生了同樣的事情, –

+1

@ImaniJackson @Mikko發佈的兩行必須與'def main ()'(因此,不需要縮進),**不是與main()函數代碼相同的級別。 – Neitsa

相關問題