0

I'm new to scripting / programming and I have a simple script here that takes a .txt file as an input. Within that txt file is a list of encoded data. I am trying to decode them line by line using the subprocess module. However, when I run the script to decrypt, I get an error because the program is adding \n at the end of each encoded line. How can I remove \n? I attached a screenshot to show you what I see when debugging it.enter image description here

#!/usr/bin/env python3

import os
import subprocess

path = "/path"
key = os.environ.get("KEY")
file = input("Filename?: ")
infile = open(file, "r")

for line in infile:
    subprocess.call([path, "decrypt", "-d", line, "-k", key])
jayteezer
  • 115
  • 2
  • 13

1 Answers1

1

You have to use rstrip() in the following way:

mystring = "alkjerfwoij212jh23\n"
mystring.rstrip('\n')
'alkjerfwoij212jh23'

Here you can find more info

Lews
  • 426
  • 4
  • 9