0

标题基本上说明了一切。这是我的脚本:

    keepProgramRunning = True
a = int(input("Type a value for a: "))
b = int(input("Type a value for b: "))
print("Result when multiplying: ", a*b)
print("Result when dividing: ", a/b)
print("...", a-b)
print("...", a+b)

在没有自动关闭 cmd 的情况下,我如何在输入 a 和 b 的值后查看结果。

4

2 回答 2

3

最简单的方法是等待用户输入

在最后添加:

input("Press enter to close")

或者,如果您从命令行运行脚本,脚本结束后窗口不会消失。

于 2012-10-13T10:33:09.770 回答
1

等待另一个输入

keepProgramRunning = True
a = int(input("Type a value for a: "))
b = int(input("Type a value for b: "))
print("Result when multiplying: ", a*b)
print("Result when dividing: ", a/b)
print("...", a-b)
print("...", a+b)
input("Press [enter] to continue..")
于 2012-10-13T10:32:53.430 回答