Why I get output with b and ''?
import subprocess
result = subprocess.run(['php', 'index.php'], stdout=subprocess.PIPE, check=True)
print(result.stdout)
Output => b'Hello'
In Php I have just echo().
Why I get output with b and ''?
import subprocess
result = subprocess.run(['php', 'index.php'], stdout=subprocess.PIPE, check=True)
print(result.stdout)
Output => b'Hello'
In Php I have just echo().
result.stdout
is a bytes
object, and the bytes.__str__()
methods returns its representation (see repr()
).
Try with print(result.stdout.decode('utf-8'))
to decode the bytes as UTF-8.
Suggested reading: Unicode HOWTO