Capturing output of os.system to a string

Lie Ryan lie.1296 at gmail.com
Mon Nov 23 20:40:00 EST 2009


gerry.butler wrote:
> How do I capture output to a string? For example, the output of
> os.system('whoami').
> 
> I guess I need to redirect stdout, but I'm a total beginner, and I
> haven't been able to find out from the tutorials how to do this.
> 

You can't with os.system; use subprocess module instead.



More information about the Python-list mailing list