Форум сайта python.su
0
В чем различие? что лучше использовать?
и немного кода:
if not(call(test, shell=True)):
result='OK'
else:
result=test
print(test_name + ‘ … ’ + result)
Офлайн
-2
А где ты этот call() взял?
Подозреваю, что он возвращает код возврата программы.
Офлайн
857
>>> import subprocess >>> print(subprocess.getstatusoutput.__doc__) Return (status, output) of executing cmd in a shell. Execute the string 'cmd' in a shell with os.popen() and return a 2-tuple (status, output). cmd is actually run as '{ cmd ; } 2>&1', so that the returned output will contain output or error messages. A trailing newline is stripped from the output. The exit status for the command can be interpreted according to the rules for the C function wait(). Example: >>> import subprocess >>> subprocess.getstatusoutput('ls /bin/ls') (0, '/bin/ls') >>> subprocess.getstatusoutput('cat /bin/junk') (256, 'cat: /bin/junk: No such file or directory') >>> subprocess.getstatusoutput('/bin/junk') (256, 'sh: /bin/junk: not found') >>>
Офлайн