问题描述
我怎么能打印到控制台而不用滚动到新行?
每个打印声明?
我想要在控制台中打印一个倒数,但是对于每个计数它会滚动屏幕(当然)
。
还有另外一种方法吗?
这是现在的简单脚本
print" Closing window in:"
for second in range (10):
time.sleep(1)
打印`10秒`+ +秒'
谢谢
/ totte
使用ncurses。
Diez
这对我有用:
导入时间,sys
范围内的秒数(10):
time.sleep(1)
sys.stdout.write(`10 -second` +" seconds")
sys.stdout.flush()
使用ncurses。
Diez
-
Hi,
How can I print to the console without having it scrolling to a new line for
each print statement?
I want to print a count down in the console, but for each count it scrolls
the screen (of course).
Is there another way?
Here is the simple script for now
print "Closing window in :"
for second in range(10):
time.sleep(1)
print `10-second` +" seconds"
thanks
/totte
Use ncurses.
Diez
This works for me:
import time, sys
for second in range(10):
time.sleep(1)
sys.stdout.write(`10-second` + " seconds ")
sys.stdout.flush()
Use ncurses.
Diez
--
http://mail.python.org/mailman/listinfo/python-list
这篇关于打印到控制台(无滚动)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!