【发布时间】:2017-12-30 21:00:55
【问题描述】:
我是 Python 新手,刚刚开始编写自己的程序。
我有一些使用 IDLE 创建的程序。这些程序会运行,但输出会在屏幕上显示大约 1/4 秒,然后才会消失...
我在互联网上进行了搜索,但没有找到解决方案...有人可以解释为什么会发生这种情况,以及如何“应对”它吗?
注意:我是双击文件
谢谢!
代码示例:
def loader():
percentage = float(input("what percentage do you want?"))
x = 0
print("\nGoal:{} %".format(percentage))
if percentage <= 100 and percentage > 0:
while x < percentage:
x+=1
print("Loading...{}%".format(x))
else:
print ("Error, you can't overload/underload")
loader()
或
def trinomial():
a = float(input("a?"))
b = float(input("b?"))
c = float(input("c?"))
print("\n a = {}\n b = {} \n c = {}".format(a,b,c))
print("So you are trying to find x for \n {}x^2 + ({}x) + ({})".format(a,b,c))
delta = b**2 - (4 * a * c)
if delta > 0:
x1 = (-b - sqrt(delta))/(2*a)
x2 = (-b + sqrt(delta))/(2*a)
print("For x = {} or x = {}, the trinomial is solved".format(x1, x2))
elif delta < 0:
print ("No values of x possible")
elif delta == 0:
#I know, I could have used "else"
x1 = -b/(2*a)
print("For x = {} the trinomial is solved".format(x1))
trinomial()
【问题讨论】:
-
你是如何运行程序的?通过空闲?通过终端?还是双击脚本?
-
@AdamSmith 双击
-
请分享程序代码
-
你的代码在哪里?
-
这里的代码实际上几乎是无关紧要的。 (或者我应该说可能几乎无关紧要!)
标签: python python-3.x output