你如何在 python 2.7 中覆盖以前的打印?我正在制作一个简单的程序来计算 pi。这是代码:
o = 0
hpi = 1.0
i = 1
print "pi calculator"
acc= int(raw_input("enter accuracy:"))
if(acc>999999):
print "WARNING: this might take a VERY long time. to terminate, press CTRL+Z"
print "precision: " + str(acc)
while i < acc:
if(o==0):
hpi *= (1.0+i)/i
o = 1
elif(o==1):
hpi *= i/(1.0+i)
o = 0
else:
print "loop error."
i += 1
if i % 100000 == 0:
print str(hpi*2))
print str(hpi*2))
它基本上在 100000 次计算后输出当前的 pi。我怎样才能让它覆盖以前的计算?