【问题标题】:UnicodeDecodeError is showing on the window ........... how to solve it? [duplicate]UnicodeDecodeError 出现在窗口............如何解决? [复制]
【发布时间】:2020-06-01 03:01:17
【问题描述】:

我只是从一个文件中读取,但为什么会显示错误?如何摆脱它?

【问题讨论】:

  • Google "python docx UnicodeDecodeError" 你可以找到一些其他类似的问题
  • 请将代码和错误以文本形式发布,而不是屏幕截图。它更容易阅读,我们可以复制/粘贴示例,问题看起来更统一。

标签: python python-3.x file


【解决方案1】:

你好 docx 是微软普通 python with open 构建的特殊扩展,仅支持 .csv .txt 等 RAW 数据文件。使用docx 库读取 docx 文件 example 如下。

import docx

# open connection to Word Document
doc = docx.Document("zen_of_python.docx")

# read in each paragraph in file
result = [p.text for p in doc.paragraphs]

【讨论】:

  • 现在显示 ModuleNotFoundError
  • 从给定链接安装所需的库,该链接在答案中的 docx 中是超链接的。
猜你喜欢
  • 1970-01-01
  • 2012-02-05
  • 1970-01-01
  • 1970-01-01
  • 2012-01-09
  • 2018-12-04
  • 2013-10-16
  • 2020-01-15
  • 2012-01-15
相关资源
最近更新 更多