I captured the standard output of an external program into a bytes object:
>>> from subprocess import *
>>> command_stdoutstdout = Popen(['ls', '-l'], stdout=PIPE).communicate()[0]
>>>
>>> command_stdoutstdout
b'total 0\n-rw-rw-r-- 1 thomas thomas 0 Mar 3 07:03 file1\n-rw-rw-r-- 1 thomas thomas 0 Mar 3 07:03 file2\n'
I want to convert that to a normal Python string, so that I can print it like this:
>>> print(command_stdoutstdout)
-rw-rw-r-- 1 thomas thomas 0 Mar 3 07:03 file1
-rw-rw-r-- 1 thomas thomas 0 Mar 3 07:03 file2
How do I convert the bytes object to a str with Python 3?
See How to convert string to bytes in Python 3 for the other way around.