简体   繁体   English

\\r 和 \\b 在 Python 中不起作用? (如何擦除一行?)

[英]\r and \b not working in Python? (how to erase a line?)

In the new python /r and /b don't work (I am using windows 10 and repl.it)在新的 python 中 /r 和 /b 不起作用(我使用的是 windows 10 和 repl.it)

Is there an easy way to make a line look like its backspacing itself?有没有一种简单的方法可以让一条线看起来像它的退格本身?

import sys
print("FAILED...")
sys.stdout.write("\033[F") #back to previous line
sys.stdout.write("\033[K") #clear line
print("SUCCESS!")

doesn't work either /\\ |也不起作用/\\ |

The interpretation of the control characters depends entirely on the rendering engine for the target device.控制字符的解释完全取决于目标设备的渲染引擎。 For instance, if you're writing to a paper-based output -- say, an archaic teletype 33 terminal -- there's no way you can erase text.例如,如果您要写入基于纸张的输出——例如,一个古老的电传打字机 33 终端——则无法擦除文本。 Device drivers differ in what controls they support and how.设备驱动程序在支持哪些控件以及如何支持方面有所不同。

You need to check the documentation for the device, whether an xterminal, a command window, or whatever -- how does that channel interpret those characters?您需要检查设备的文档,无论是 xterminal、命令窗口还是其他任何东西——该通道如何解释这些字符?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM