Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- https://stackoverflow.com/questions/30664263/return-value-from-one-python-script-to-another
- '''
- '''
- pass an argument to another script
- retrieve an output from another script to original caller
- '''
- #######################################
- #Script 1
- import sys
- import subprocess
- s2_out = subprocess.check_output([sys.executable, "script2.py", "34"])
- print(s2_out)
- #####################################
- #script 2
- import sys
- def main(arg):
- print("Hello World"+arg)
- if __name__ == "__main__":
- main(sys.argv[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement