Conocía os.system, pero hoy en la python-es han comentado un par de opciones mas; popen:
import os
data=os.popen('ls').read()
file=open('fichero.txt','w')
file.write(data)
file.close()
Y con commands:
import commands
out = commands.getoutput('ls')
f = file('lsout.txt', 'w')
f.write(out)
f.close()
2 comentarios:
Está muy bueno el aporte, me pongo a pensar si se puede hacer un chat interno, mmmmm genial gracias...
Excelente, justo lo que necesitaba.
Publicar un comentario