【问题标题】:How can I change the color of the error output in the VS code terminal?如何更改 VS 代码终端中错误输出的颜色?
【发布时间】:2023-03-27 10:40:02
【问题描述】:

我使用 vscode 进行 python 编程。如何更改终端中的彩色文本错误输出? .你能帮帮我吗?

【问题讨论】:

标签: python-3.x visual-studio-code


【解决方案1】:

您是在 Windows、Linux 还是 Mac 上这样做的?您是要更改所有输出中的颜色,并且仅在 VSC 终端中更改颜色,还是仅在一个程序中更改?你应该解释更多你想要什么。

如果你想在python中改变一个输出的颜色,那么做:

print("\033[1;44mMessage\033[0m")

其中:\033 是标识颜色的标签 [1;44m 1 是背景颜色,44m 是字体颜色,您可以替换下图中颜色代码的数字。使用\033[0m,您可以将颜色改回默认值。

以下是可用的颜色:

https://robologs.net/wp-content/uploads/2016/03/coloricos.png

(我还不能发表评论)。

【讨论】:

  • 嗨。你好吗?感谢您回答这个问题。我使用 Windows 并希望更改输出中的错误颜色,并且仅在 vsc 终端中。例如,我希望终端中的错误颜色永远为红色。如何在没有打印语法的情况下完成这项工作?我可以在 setting.json 中更改终端设置吗?
【解决方案2】:

在您的设置中试试这个:

{
  "workbench.colorCustomizations": {

                                   // whatever hex color you want
                                   // doesn't appear that opacity values work here 
    "terminal.ansiBrightRed": "#ff0"  // typically used for the error foreground
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-18
    • 1970-01-01
    • 2023-02-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-06
    • 1970-01-01
    • 2022-08-18
    相关资源
    最近更新 更多