我怎样才能覆盖Python中以前的“打印”值?
print "hello"
print "dude"
print "bye"
它将输出:
hello
dude
bye
但我想覆盖该值。
在这种情况下,输出将是:
bye
检查这个诅咒库 http://docs.python.org/3.3/howto/curses.html#what-is-curses,curses 库为基于文本的终端提供了独立于终端的屏幕绘制和键盘处理工具。一个例子:
x.py:
from curses import wrapper
def main(stdscr):
stdscr.addstr(1, 0, 'Program is running..')
# Clear screen
stdscr.clear() # clear above line.
stdscr.addstr(1, 0, 'hello')
stdscr.addstr(2, 0, 'dude')
stdscr.addstr(3, 0, 'Press Key to exit: ')
stdscr.refresh()
stdscr.getkey()
wrapper(main)
print('bye')
run it python x.py
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)