python - 在 .py 文件完成运行之前关闭 Windows Python 3.7
问题描述
我在 Spyder 中编写了一个 python 脚本,并试图在我的机器上运行它,但 Windows 上的 Python 3.7 将它关闭得很早。
我的代码是:
print('Campus Pizza Ordering Program\n')
crust = input('What crust? Regular or Wheat? ')
num_toppings = int(input('How many toppings (please enter a whole number)? '))
price = format((7 + num_toppings * 0.75),".2f") #looked up how to round to 2 decimals
print('\nYou have a '+crust+' pizza with '+str(num_toppings)+' toppings. ' +
'The final price of the pizza is $'+str(price)+".")
该程序在执行最终打印语句之前关闭。为什么?
解决方案
考虑导入时间并time.sleep(5)
在程序结束时使用,以便查看输出是否打印。
推荐阅读
- python - Apache Beam - Python:如何通过累积获得 PCollection 的前 10 个元素?
- amp-html - 从谷歌缓存提供服务时 AMP 页面显示无效
- android - 标记对拖动反应不灵敏
- javascript - Angular:想要在图表的条内显示名称
- sql-server - 如何在 SQL 中将逐行执行转换为基于 SET 的方法
- r - 如何将具有空格和 NA 的列变成一个因子?我们可以把字符变成数字吗?
- python - 在 Python 中复制 C 定点数学
- python - 试图理解为什么这段代码不返回相同的值
- python - “截断”通过 CloudFormation (SAM) 创建的 DynamoDB 表
- javascript - 当我向下滚动网站页面时,如何更新进度条?