I'm learning subprocess
, but I have a little confusion with this code:
import subprocess
proc = subprocess.Popen('lspci', stdout=subprocess.PIPE)
for line in proc.stdout:
print(line)
Output:
b'00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor DRAM Controller (rev 09)\n'
b'00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)\n'
As you can see, the output is formated. But I dont know why there is the character b''
and the \n
at the end.
If I run this command in my terminal, there aren't these char.
Normal output:
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor DRAM Controller (rev 09)
00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor Graphics Controller (rev 09)
How could I remove them?