Reputation: 4225
I am using Python sub process to execute command as shown below:
process = subprocess.Popen(['debug', 'file.tgz'],
stdout=subprocess.PIPE,stderr=subprocess.PIPE)
while True:
output = process.stdout.readline()
print(str(output.strip()).encode())
return_code = process.poll()
if return_code is not None:
break
What i am getting out put is shown below:
b"b'Registers:'"
And this is what i am expecting.
Registers:
I am using encode but still seeing same out put. If i run the same process on command line i am getting the same desired out put.
How can i remove these special characters?
Upvotes: 0
Views: 2706
Reputation: 6930
b'...'
print(output.decode('utf8', errors='strict').strip())
Upvotes: 4