Python脚本没有调用main函数,说进程用退出代码0完成

时间:2015-04-23 06:57:08

标签: python python-3.x pycharm

我正在使用pycharm,它说Process没有我的restaurant_list或其后的任何内容,退出代码为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()

1 个答案:

答案 0 :(得分:1)

您需要在文件末尾添加以下内容:

{{1}}

...打电话给你的主要功能。还要确保您的PyCharm配置为运行正确的脚本。