[英]Print Terminal Output Python
Is there a way to assign the terminal output to a varibale then print it to the screen, using os.popen()
有没有办法将终端 output 分配给变量,然后使用
os.popen()
将其打印到屏幕上
For example:例如:
import os
output = os.popen("dir")
print(output)
Is this possible?这可能吗?
Yes it is possible but you should do it like this:是的,这是可能的,但你应该这样做:
import os
output = os.popen("dir")
preprocessed = output.read()
print(preprocessed)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.