开发者

Python Command Line input? [duplicate]

This question already has answers here: read subprocess stdout line by line (10 answers) Closed 29 days ago.

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 strs 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜