I am trying to replace unprintable characters from a line in python before writing the same to a file.
import re
line = 'Testing offset [4,-5]'
re.sub("[^[:print:]]", '?', line)
>> line
'Testing offset [4,-?'
I want the output to be like
'Testing offset [4,-5]'
Can somebody help on what I'm doing wrong?