0

When i execute the below code the output is coming with new line.

import os import sys import subprocess password_string='abc_123' cmd=["java", "-cp", "ABC.jar","com.sc.tsaas.EncryptionDecryptionAES",password_string] i=subprocess.Popen(cmd,stdout=subprocess.PIPE).communicate()[0] print (i) 

Output : aSjD9H2NfmX02KpFg==

New line is coming in output and need your help to solve this.

1
  • There's always a newline there; the only reason you don't see it in shell is that shells strip trailing newlines from command substitution output. Commented Jan 6, 2022 at 12:00

1 Answer 1

2

To strip the newline, do i=subprocess.Popen(cmd,stdout=subprocess.PIPE).communicate()[0].rstrip("\n")

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.