The b
sigil indicates the type of the data; it's not part of the value. It shows that this is a bytes
value, not a str
value.
You want to use universal_newlines=True
if your Python version is new enough (but then you'll probably also want to switch to subprocess.run()
).
On older Python versions, p2.decode('utf-8')
will return the value converted to a string; but then you need to know the correct encoding.
Going forward, this keyword parameter is called simply text
since Python 3.7, though the alias universal_newlines
will continue to work. It was always a bit of a misnomer, though; text
is a better summary of all the small things it does.