Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python print something like warning or error (shown in red) [duplicate]

I've seen some libs print things via warning or error stream (e.g. tqdm), and the text is shown in red.

So my question is: How to print arbitrary text like that? I plan to highlight some stdout info in my code.

like image 443
Flicic Avatar asked Apr 26 '26 14:04

Flicic


1 Answers

Is this what you want?

from colorama import Fore

print(Fore.RED + 'This is a warning!')

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!