My Python script will run a bunch of shell scripts that output either 200 SOLUTIONS_REVISION
or 开发者_Python百科400 SOLUTIONS_REVISION
when run. The 200
in the output indicates success and the 400
indicates failure.
How can I capture these "returned" strings as str
s in the Python code, for further processing?
If you're going to run the command from your Python script then you want to look at subprocess
with its stdout
arguments. If you're going to run both that script and the Python script from a separate shell script then you want to pipe from one to the next and then read from sys.stdin
.
精彩评论