Q:

Python subprocess Messy output

With the following code:
output = subprocess.check_output(['wmic', 'PATH', 'Win32_videocontroller', 'GET', 'description'])
    print(output , "\n")

I get the next output:
b'Description                \r\r\nNVIDIA GeForce 710M        \r\r\nIntel(R) HD Graphics 4000  \r\r\n\r\r\n'

When I use the commando wmic path win32_videocontroller get desriptionin my CMD I get only the videocard info back. Is this possible in python aswell? With out the /r/r/r/r things?

A:

Use the argument "universal_newlines=True" when you call the function:
output = subprocess.check_output(['wmic', 'PATH', 'Win32_videocontroller',  'GET', 'description'], universal_newlines=True)
print(output , "\n")

