To get a string as output, use “output. stdout. decode(“utf-8”)” method. You can also supply “text=True” as an extra argument to the subprocess.
The Python subprocess call() function returns the executed code of the program. If there is no program output, the function will return the code that it executed successfully. It may also raise a CalledProcessError exception.
I want to be able to define a variable by the return value of a script. This is what I currently have:
sum_total_earnings_usd = subprocess.call([SCRIPT, "-d", date])
I have checked the return value of SCRIPT, however, when I try and set this variable, it always returns 0 ( http://docs.python.org/library/subprocess.html#subprocess.call ). How would I run this script and capture the return value to store as a variable?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With