hide cmd in python

import ctypes
ctypes.windll.user32.ShowWindow( ctypes.windll.kernel32.GetConsoleWindow(), 6 )

Here is what the above code is Doing:
1. Importing the ctypes module
2. Getting the handle to the console window using GetConsoleWindow()
3. Showing the console window using ShowWindow()