如何在 VS 代码输出选项卡中使用 \r 转义序列? [英] How to use \r escape sequences in VS-code output tab?

查看:39
本文介绍了如何在 VS 代码输出选项卡中使用 \r 转义序列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下 Python 代码:

The following Python code:

print("hello\rworld")

... 在 Python REPL(从 Terminal.app (MacOS) 或 VS-code 终端启动)和 Jupyter Notebook 下打印 world.

... prints world under a Python REPL (launched from either Terminal.app (MacOS) or VS-code terminal) and Jupyter Notebook.

然而,VS-code 输出选项卡似乎忽略了 ANSI 转义序列:

However, the VS-code output tab seems to ignore the ANSI-escape sequences:

是否可以覆盖此行为?

推荐答案

您可以尝试不使用 Code Runner 扩展,而是使用 Python 扩展来执行您的代码.这样,执行发生在终端中,\r 更有可能执行换行而不是换行.

You could try not using the Code Runner extension and use the Python extension to execute your code instead. That way the execution occurs in the terminal where there's a better chance \r will do a line feed instead of a newline.

这篇关于如何在 VS 代码输出选项卡中使用 \r 转义序列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆