-1

So i have string that i want to split bט new line: This string is process output:

tshark_path=r'C:\Program Files\Wireshark\tshark.exe'
process = Popen([tshark_path, "-D"], stdout=PIPE, shell=True)
(output, err) = process.communicate()
exit_code = process.wait()

lines = [s.strip() for s in output.splitlines()]
for line in lines:
    print(line)

And each print line always start with 'b' although this 'b' sign exist only once in my output variable (the process output)

falukky
  • 1,099
  • 2
  • 14
  • 34

1 Answers1

0

b means a byte Literal. Please use decode to get string.

from subprocess import Popen, PIPE

tshark_path=r'dir/w'
process = Popen([tshark_path, "-D"], stdout=PIPE, shell=True)
(output, err) = process.communicate()
exit_code = process.wait()

lines = [s.strip() for s in output.splitlines()]
for line in lines:
    print(line.decode('utf-8'))
yaho cho
  • 1,779
  • 1
  • 7
  • 19