目标:我想从word文件中读取文本,然后将每个字符的ascii值增加一个预定义的数字(某种编码),并将其保存到同一个文件中。例如:“A”的ascii是65,所以我需要它变成75。我正在写下面的代码,在这一点上是卡住了。 `你知道吗
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
现在我得到的输出是这样的
This is just a test of what I?m gonna make. Fingers crossed?
原来的字符串是
This is just a test of what I’m gonna make. Fingers crossed…
如何用相应的ascii字符替换Unicode字符以便继续?请提供一些建议。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐