Execute shell command and get the result by python
paul
posted @ Fri, 15 May 2009 20:57:25 +0800
in coding life
, 2662 readers
import os
result = os.popen( 'your command' ).read()
print result
result = os.popen( 'your command' ).read()
print result
os.popen() can invoke the inputted command and grab its output as if it is a file-like object.
This work is licensed under a Creative Commons Attribution 3.0 Unported License.