I am reading a word file using below code :
import win32com.client as win32
word = win32.dynamic.Dispatch("Word.Application")
word.Visible = 0
doc = word.Documents.Open(SigLexiconFilePath)
I get strings from the file which has lot of non-printable characters:
str = "\xa0keine\xa0freigäbü\xa0\x0b\r\x07"
I tried below codes to remove non-printable characters :
import string
str = "\xa0keine\xa0freigäbü\xa0\x0b\r\x07"
filtered_string = "".join(filter(lambda x:x in string.printable, str))
This gives me below output:
keinefreigb\x0b\r
Other piece of code which I tried :
str = str.split('\r')[0]
str = str.strip()
This gives me below output:
keine\xa0freigäbü
How can i remove all these non-printable characters to get below desired output using minimum code :
keine freigäbü