RosettaCodeData/Task/Execute-a-system-command/Python/execute-a-system-command-2.py
Ingy döt Net 764da6cbbb CDE
2013-04-10 16:57:12 -07:00

5 lines
242 B
Python

import subprocess
# if the exit code was non-zero these commands raise a CalledProcessError
exit_code = subprocess.check_call(['ls', '-l']) # Python 2.5+
assert exit_code == 0
output = subprocess.check_output(['ls', '-l']) # Python 2.7+