如何防止Python exe文件在完成任务后关闭窗口?

如何防止Python exe文件在完成任务后关闭窗口?,python,cmd,exe,Python,Cmd,Exe,我分配了一个每周储蓄计算器,在生成exe文件并运行它之后,它将打开cmd,提示输入所需内容,并在计算和显示列表后立即关闭。我希望程序窗口在显示列表时保持打开状态,以便用户可以根据需要做笔记 weeks = [] #Creates a list with each week's amount for the selected number of periods. def create_list(amount, periods): counter = 0 savings = 0

我分配了一个每周储蓄计算器,在生成exe文件并运行它之后,它将打开cmd,提示输入所需内容,并在计算和显示列表后立即关闭。我希望程序窗口在显示列表时保持打开状态,以便用户可以根据需要做笔记

weeks = []
#Creates a list with each week's amount for the selected number of periods.
def create_list(amount, periods):
    counter = 0
    savings = 0
    while (counter < periods):
        savings += amount
        weeks.append(savings)
        counter += 1
#Formats each item in the list and prints it separately.
def display(lists):
    i = 1
    for entry in lists:
        print ("On period {} you should deposit ${} ".format(str(i), entry))
        i += 1

def main():
    amount = int(input("Enter savings amount you want to start with: "))
    periods = int(input("For how many periods do you want to save?: "))
    print()
    create_list(amount, periods)
    display(weeks)
    total = sum(weeks)
    print ("\nAfter {} periods you will have ${} saved.".format(periods, total))

main()   
weeks=[]
#创建一个列表,列出所选期间数的每周金额。
def创建_列表(金额、期间):
计数器=0
节省=0
而(计数器<周期):
储蓄+=金额
周。追加(节省)
计数器+=1
#设置列表中每个项目的格式并单独打印。
def显示(列表):
i=1
对于列表中的条目:
打印(“在{}期间,您应存入${}”。格式(str(i),条目))
i+=1
def main():
amount=int(输入(“输入您希望以以下开头的储蓄金额:”)
句点=int(输入(“要保存多少句点?:”)
打印()
创建_列表(金额、期间)
显示(周)
总计=总和(周)
打印(“\n在{}个期间之后,您将保存${}”。.format(期间,总计))
main()

如何使用
输入
?类似于
input(“按Enter键继续”)
main末尾的
Python不会关闭窗口。无论您使用什么来运行脚本,都会在脚本结束时执行。谢谢Ismael!这是一个简单而有效的解决办法。