Skip to content

Instantly share code, notes, and snippets.

@RDCH106
Created October 5, 2016 10:06
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RDCH106/6562cc7136b30a5c59628501d87906f7 to your computer and use it in GitHub Desktop.
Save RDCH106/6562cc7136b30a5c59628501d87906f7 to your computer and use it in GitHub Desktop.
ANSI Colors Fix for Python in Windows
import os
import platform
if os.name == 'nt' and platform.release() == '10' and platform.version() >= '10.0.14393':
# Fix ANSI color in Windows 10 version 10.0.14393 (Windows Anniversary Update)
import ctypes
kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
@RDCH106
Copy link
Author

RDCH106 commented Oct 5, 2016

Output Before:

ansi_win_before

Output After (applying Fix):

ansi_win_after

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment