Reputation: 493
I have 2 scripts, and I need to run one script from another, get its output, and assign it into variable inside the first script, and use it.
The second script need to give me some output of a text within 5-7 characters.
I tried to run this in my first script, but it didn't work.
import subprocess
capnum = subprocess.run(["../python3 test-ver2.py"])
print("Result: " % capnum.returncode)
Upvotes: 0
Views: 64
Reputation:
I believe subprocess.getoutput()
is what you're looking for:
import subprocess
capnum = subprocess.getoutput("..\\python3 test-ver2.py")
print(f"Result: {capnum}")
Upvotes: 2