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
  • 32,991
  • 4
  • 47
  • 70
Sam H
  • 118
  • 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,404
  • 1
  • 14
  • 26