This is my python code.
print('\x1b[6;30;42m' + 'Success!' + '\x1b[0m')
I'm trying to see a green background color on the cmd.exe. It's strange. It works properly when I execute it with command 'start /B python x.py'. But it doesn't work when I execute it with command just 'python x.py'
You can see it from following picture. Could you please give some advice for this?
When you run your script with start /B python x.py
the start
command is creating a new console window with different settings that happen to support ANSI colors. Windows command prompt doesn't process ANSI escape sequences unless they're explicitly enabled.
Try this
import os
os.system('')
print('\x1b[6;30;42m' + 'Success!' + '\x1b[0m')
The output