A quick solution using popen :
import os
result=os.popen('command').read()
print result
where command is your command (expl. on windows: dir,ipconfig,...)
If you expect more than a line and want each word in a list:
import os,string
result=string.split(os.popen('dir/w').read())
Source of this
Affichage des articles dont le libellé est os. Afficher tous les articles
Affichage des articles dont le libellé est os. Afficher tous les articles
mardi 20 février 2007
[Python] How to get the output from os.system() into a variable ?
Publié par
Francois Schnell
à
09:28
0
commentaires
Inscription à :
Articles (Atom)
