【发布时间】:2017-03-13 05:53:20
【问题描述】:
alphabet_dic = ['a','b','c','d','e','f','g','h','i','j','k','l','n','o','p','q','r','s','t','u','v','w','y','z','m']
doc = Document('test3.docx')
firstSen = doc.paragraphs[0].text
print (firstSen)
indexLetters = 0
while indexLetters < len(c_dic):
d_dic = c_dic[indexLetters]
indexLetters += 1
secondSen = firstSen.replace(d_dic,"")
print (secondSen)
测试文档包含句子“Hello There”。 我正在尝试创建一个循环,在其中检查字典中是否有大量特定字母,然后慢慢循环并从“Hello There”中删除字母。
想法:
Sentence = Hello There
helloDic = ['h','e','l','o']
Desire Result = Tr
有什么建议或更好的方法吗?
【问题讨论】:
标签: python python-3.x ms-word