Home > database >  while using subprocess in python the output is coming with new line
while using subprocess in python the output is coming with new line

Time:01-06

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.

CodePudding user response:

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

  •  Tags:  
  • Related