Re: [問題] 如何持續更新print內容

看板Python作者 (ccccccc)時間6年前 (2018/09/22 21:49), 編輯推噓0(003)
留言3則, 2人參與, 6年前最新討論串2/2 (看更多)
有找到一個比\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變數 : 還請大大們教學,感恩 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.163.214.81 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1537624189.A.F5D.html

09/25 10:58, 6年前 , 1F
請問這是for python2.x嗎?我在3跑有error
09/25 10:58, 1F

09/25 10:59, 6年前 , 2F
我再嘗試看看,感謝分享
09/25 10:59, 2F

09/25 12:04, 6年前 , 3F
我是2.7 on Ubuntu std lib. Windows要安裝curses mod.
09/25 12:04, 3F
文章代碼(AID): #1RfaXzzT (Python)
討論串 (同標題文章)
文章代碼(AID): #1RfaXzzT (Python)