0

What is the best way to execute a single-line of Python 3 and return the result to a Python 2 program. For example:

#!/usr/bin/env python2 
# Not valid code
pwsd = exec("python3 -c 'import crypt; print(crypt.crypt(\"<password_str>\",salt=crypt.METHOD_SHA512))'")
2

1 Answer 1

0

Got it. Thanks Anentropic.

subprocess.check_output(['python3', '-c', 'import crypt; print(crypt.crypt("<password_str",salt=crypt.METHOD_SHA512))'])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.