短缺問題
是否有可能/實用的編寫和更新多行(包含\n
)在Windows終端上串?Python的多線路終端更新
背景
我已經調查curses,但它只能是Unix的。我看到了一些其他的Window端口,但是Windows XP對於他們來說是一個實驗操作系統,這有點令人不安。我希望將它用作診斷功能的一部分,以在主要終端應用程序上顯示鏈接狀態,消息速率等(請注意,某些變體確實有wxPython GUI輸入)。這就是說,使用Cygwin是不理想的,並希望僅使用sys模塊找到解決方法。
我已經試過如下:(注意,我希望他們失敗了,但希望我是錯的)
嘗試1:修改字符串,但它是所有在1號線
sys.stdout.write("\r")
sys.stdout.write("This is a multi-line screen print test")
sys.stdout.write("Line 1")
sys.stdout.write("Line 2")
sys.stdout.flush()
嘗試2 :不更新但打印所有行
sys.stdout.write("\r")
sys.stdout.write("This is a multi-line screen print test\n")
sys.stdout.write("Line 1 \n")
sys.stdout.write("Line 2\n")
sys.stdout.flush()