Issue
I have 2 scripts and at the end of the first a want to pass data to the second script: Here's my code, this is what I tried but I can't get anything:
user.py
import subprocess
command = "python C:\Users\...\credentials.py"
JSON = subprocess.check_output(command, shell=True)
print JSON
credentials.py (relatively simple)
# bla bla bla
return JSON_credentials
It returns nothing and I want to know if there is a way to do what I need to do (obvious ahah)
Thanks for your help !
Solution
The check_output
method captures output from stdout. return
does not write anything to stdout. That keyword is used to pass data within a single Python program.
Try something like:
import sys
# bla bla bla
sys.stdout.write(JSON_credentials)
Or simply:
# bla bla bla
print JSON_credentials
Answered By - Jamie Counsell
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.