I am trying to get colours to work in Python using windows cmd but it is not working. I've tried a few packages, but they all result in something similar.
At the moment, my code looks like this:
from colors import *
print(color('some text', fg='rgb(255, 0, 0)'))
However, this just prints [38;2;255;0;0msome text[0m into the console in white.
What am I doing wrong here?
EDIT: I am using this package .
EDIT2: I need to print many different exact RGB values.
EDIT3: The below code works for colorama, but afaik colorama doesn't allow you to specify exact RGB values.
from colorama import init, Fore, Back, Style
init(convert=True)
print(Fore.RED + 'some red text')
Re-enable ANSI console color for Windows 10.16257 and later : run
reg add HKCU\Console /v VirtualTerminalLevel /t REG_DWORD /d 1
Restart Windows command prompt ( cmd.exe
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.