【发布时间】:2019-08-08 13:52:58
【问题描述】:
使用 python 3 打开 docx 文件时发生错误
当我尝试运行时:
file=open("jinuj.docx","r",encoding="utf-8").read()
发生以下错误
319 # decode input (taking the buffer into account)
320 data = self.buffer + input
--> 321 (result, consumed) = self._buffer_decode(data, self.errors, final)
322 # keep undecoded input until the next call
323 self.buffer = data[consumed:]
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 11: invalid start byte
【问题讨论】:
-
docx 文件是 xml 文件的压缩包。因此,由于它甚至不是文本,它肯定不是 UTF-8 编码的......
标签: python python-3.x utf-8 python-unicode