User Profile
Collapse
-
cool! thanks a lot. the python version i used was 2.2.... that's why...... -
-
about data structure --- 'Set'
Hello everyone,
If you look at the following tutorial, you will find the great advantage of using 'set' as a data structure.
http://docs.python.org/tut/node7.htm...00000000000000
But it seems I need to import something before using it, otherwise it'll not be recognised. Could anybody please tell me what I should import?
Thanks in advance!... -
Thanks for all of your replies.
"var = commands.getout put(cmd)" seems to be good. However, it doesn't check if the command has been executed successfully.
What i want is if it's executed successfully, then write the stdout to a variable, otherwise die with an error message..
If i use "if os.system(cmd) != 0:" to check it before running "var=commands.g etoutput(cmd)", then...Leave a comment:
-
how to get the stdout of the script that os.system executes
i know that in python, os.system(cmd) can be used to execute a script or command, and the return value is 0 if successful, rather than the standard output of the script that it executes.
e.g.
>>> a=os.system("ec ho hello")
>>> a
0 (rather than "hello")
my question is how to direct the standard output into a variable in my python script.
No activity results to display
Show More
Leave a comment: