0

I'm trying to save ('ls -l') results in a variable using subprocess.Popen, my problem is when I print the array it has '\n' for every element.

this is my code

result = subprocess.Popen("ls -1 | sed -e 's/\..*$//'", shell=True, stdout=subprocess.PIPE)
variables = result.stdout.readlines()

I can't use strip() since variables is not a list.

is there any way to remove those '\n' ?

Oz Giat
  • 127
  • 3
  • 10

0 Answers0