As the documentation for subprocess.check_output explains:
By default, this function will return the data as encoded bytes. The actual encoding of the output data may depend on the command being invoked, so the decoding to text will often need to be handled at the application level.
So what you get back is a bytes object that contains the output of your command as encoded bytes. You can see this when you print the object; bytes literals have a b in front of the quotes both when printed and when the repr is printed:
>>> x = b'foo bar' >>> print(x) b'foo bar' >>> x # basically the same as print(repr(x)) b'foo bar'
In order to get a proper string out of this, you need to decode the bytes object using bytes.decode(). Note that in order to decode bytes into a string, you need to know what encoding the data is encoded as. Very commonly, this will be utf-8 in which case you do not need to pass any argument to it:
>>> x.decode() 'foo bar' >>> print(x.decode()) foo bar