1

Is there a way to assign the terminal output to a varibale then print it to the screen, using os.popen()

For example:

import os
output = os.popen("dir")
print(output)

Is this possible?

James
  • 29,484
  • 4
  • 43
  • 62
Sam H
  • 108
  • 11

1 Answers1

2

Yes it is possible but you should do it like this:

import os
output = os.popen("dir")
preprocessed = output.read()
print(preprocessed)
Farshid616
  • 1,114
  • 1
  • 11
  • 25