更改控制台输出的一部分或一部分

时间:2018-04-23 20:23:55

标签: d

有没有办法改变已经写入控制台的东西?

例如,我想更改已经写过的行:

_ Foo

......对此:

+ Foo

虽然理想情况下这适用于Windows(powershell或命令行)和Linux(shell),但只支持Linux的解决方案。

我不熟悉标准输入和输出,如果这是一个基本问题,请原谅我。

1 个答案:

答案 0 :(得分:1)

如果光标仍在同一行,您可以执行此操作:

profile.set_preference('print.always_print_silent',True)

但这不起作用:

write("_ Foo");
stdout.fllush;//To force the displaying of the text now.
writeln("\r+ Foo"); //Output will be replaced


您也可以单独删除字符:

writeln("_ Foo"); //Equivalent to as `write("_ Foo\n");`
stdout.fllush;//To force the displaying of the text now
writeln("\r+ Foo"); //Output will not be replaced (it will be on new line).


我还没有找到擦除前一行的方法(我认为这是有意的)。

相关问题