I am reusing a code from python2 in python3.
value = subprocess.check_output("/usr/bin/python3 tc.py " + sys.argv[1], shell=True)
search = "TC specific commands"
read_file = open("input.py", "r")
write_file = open("output.py", "w")
for line in read_file:
if search not in line:
write_file.write(line)
else:
line = line + "\n" + value
write_file.write(line)
My tc.py has code like
print ('<Some_text>\n' + \ '<Some_text2>\n' + \ '<Some_text3>')
In python2 the above program used to write following lines in output.py
<Some_text> <Some_text2> <Some_text3>
In python3, I got a syntax error
TypeError: Can't convert 'bytes' object to str implicitly
So, I change my above script as:
line = line + "\n" + value -> line = line + "\n" + str(value)
the output is coming like
b'<Some_text>\n<Some_text2>\n<Some_text3>
How can I make output in python 3 same as I was getting earlier in python2?