This may be a stupid question but I have a Python script that starts a subprocess (also a Python script) and I need that subprocess to return three integers. How do I get those return values from the Python script that starts the subprocess? Do I have to output the integers to stdout and then use the check_output() function?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
The answer is Yes... I want my +15 reputation!! :-D
No, seriously... Once you start dealing with subprocesses, the only way you really have to communicate with them is through files (which is what
stdout
,stderr
and such are, in the end)So what you're gonna have to do is grab the output and check what happened (and maybe the spawned process'
exit_code
, which will be zero if everything goes well) Bear in mind that the contents ofstdout
(which is what you'll get with thecheck_output
function) is an string. So in order to get the three items, you'll have to split that string somehow...For instance: