简体   繁体   English

如何在Python中获取现有的字体颜色(CLI)?

[英]How can I get the existing font colour (CLI) in Python?

I know how to change the font colour of output in Python using this (for example) 我知道如何使用此方法更改Python输出的字体颜色(例如)

print('\\033[94m' + text)

However, the rest of the text will then stay that colour, even after the app has closed. 但是,即使关闭应用程序,其余文本仍将保持该颜色。 I could set it to a certain colour, but the user may have changed the background colour and that would be a problem, 我可以将其设置为某种颜色,但是用户可能已经更改了背景颜色,这将是一个问题,

print('\x1b\x63')  # Esc c

这将重置终端(RIS)。

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

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