【问题标题】:colored text without any module windows python没有任何模块windows python的彩色文本
【发布时间】:2021-05-28 03:48:40
【问题描述】:

我有 Windows 10。

我可以在没有任何模块的情况下在 Windows 中打印彩色文本吗? (如colorama) 如果我跑:

GREEN =  '\033[32m' 
print (GREEN + "This is some green text!")

然后我得到了←[32m这是一些绿色文字!

为什么?

【问题讨论】:

  • 您使用的是哪个 Windows“外壳”? (cmd、powershell、wsl bash?..)
  • cmd 或 powershell。

标签: python string text colors


【解决方案1】:

Vanilla cmd.exe 不支持 ANSI 转义。使用另一个终端应用程序(例如Windows TerminalConemuCmder)或查看How to make win32 console recognize ANSI/VT100 escape sequences? 在 vanilla cmd 中打开 ANSI。

【讨论】:

  • 谢谢。我将此代码运行到 Windows 终端并获取彩色文本。
猜你喜欢
  • 2011-12-28
  • 2021-12-20
  • 2011-04-11
  • 1970-01-01
  • 2021-06-28
  • 2019-03-21
  • 2014-07-20
  • 1970-01-01
  • 2014-09-03
相关资源
最近更新 更多