Objective: I want to read the text from a word file and then increment the ascii value of each character by some predefined number(sort of encoding) and save it into the same file itself. For eg : 'A' has an ascii of 65 so I need that to become 75. I'm writing this following code and is stuck at it at this point. `
import docx
from docx import Document
data = Document("C:\Python27\Testing.docx")
for n in data.paragraphs:
temp= n.text
for d in temp:
try:
temp1 = str(temp)
except UnicodeEncodeError:
temp1 = temp.encode('ascii','replace')
pass
print temp1
Now the output which I get is like this
This is just a test of what I?m gonna make. Fingers crossed?
and the original string is
This is just a test of what I’m gonna make. Fingers crossed…
how can I replace the Unicode characters with the corresponding ascii characters so that I can proceed ahead? Please provide some suggestions.