Created
February 2, 2021 05:39
-
-
Save kasimte/e420538fca82c25cbb53fb9f52a251af to your computer and use it in GitHub Desktop.
Demo of running separate python script as subprocess and capturing output.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# output.py (separate file) | |
print(37.234) | |
# capture_output_from_script.py | |
import subprocess | |
# run output.py as subprocess and capture output, format it, convert to float, and print | |
x = float(subprocess.check_output('python output.py', shell=True, text=True).strip()) | |
print(x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment