Get the color of the terimal's background to decide which color to use

There are many color that the terimal’s background can be. If the color of the information(like syntax tips or error message) is similar with the terimal it will be difficult to read.

For example, if the powershell’s color is blue, while thw error messages’color is purple, it will be difficult to see, even blind the eyes.

So is there a way to get the color of the terimal’s color and change the color in python?

Yeah, you can try to get the terminal background color, but it’s tricky and depends on the terminal. On Windows, you can use ctypes to check it. On Linux/macOS, there’s no easy way, so usually people just assume dark or light background and pick a color that is easy to read. Most of the time, it’s easier to let the user choose light or dark mode.