Re: [问题] 如何持续更新print内容

楼主: rexyeah (ccccccc)   2018-09-22 21:49:46
有找到一个比\r好用
curses (https://goo.gl/ivB5YG)
import curses
import sys
import time
from datetime import datetime
import random
def main(stdscr):
for i in range(10):
stdscr.clear()
stdscr.addstr("CurrentTime: %s\n" % datetime.now())
stdscr.addstr("Num: %d\n" % (i+1))
stdscr.addstr("Choice: %s" % ['a', 'b', 'c', 'd'][random.randint(0, 3)])
time.sleep(0.5)
stdscr.refresh()
main(curses.initscr())
※ 引述《renshin (阿信)》之铭言:
: 各位大大好
: 想请教如何持续更新显示内容
: 目前google查到都只能处理一行
: 若我的内容有多行以上可以如何达到这个功能呢?
: ex:
: 现在时间:A
: 人数:B
: 其他:C
: 以上是显示范例
: 希望能在print的时候永远只显示3行,只更新ABC变量
: 还请大大们教学,感恩
作者: renshin (阿信)   2018-09-25 10:58:00
请问这是for python2.x吗?我在3跑有error我再尝试看看,感谢分享
楼主: rexyeah (ccccccc)   2018-09-25 12:04:00
我是2.7 on Ubuntu std lib. Windows要安装curses mod.

Links booklink

Contact Us: admin [ a t ] ucptt.com