返回codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError:“ charmap”编解码器无法解码

时间:2018-11-15 22:54:54

标签: python python-3.x ms-word docx doc

  

返回codecs.charmap_decode(input,self.errors,decoding_table)[0]   UnicodeDecodeError:“ charmap”编解码器无法解码位置的字节0x81   1020:字符映射到

当我尝试读取Word文档程序docx或其中包含表格的doc时出现此消息。对于没有表格的文档,它不会引发此错误。这是程序:

with open('Testy.docx') as file:
    contents = file.read()
    a1 = "mother"
    a2 = "father"
    a3 = "sister"
    a4 = "brother"
    if a1 in contents:
        print ('best in the world')
    if a2 in contents:
        print("tough but fair")
    if a3 in contents:
        print('awesome')
    if a4 in contents:
        print("punchbag")
    else:
        print ('nothing found')

任何帮助都将受到超级赞赏

0 个答案:

没有答案