【发布时间】:2016-11-02 09:17:29
【问题描述】:
我正在使用 Python 将 word 文件转换为文本字符串。生成的文本字符串将项目符号点(在 word 文件中)转换为 (在转换后的字符串中)。如何使用 Python 从文本字符串中删除它,以便我只有没有这些框的文本字符串 ()。
from docx import Document
document = Document(file_to_read)
text_string = ''
for paragraph in document.paragraphs:
text_string += paragraph.text+"\n"# -*- coding: utf-8 -*-
print text_string
输出如下:
Computer Science fundamentals in data structures.
Computer Science fundamentals in algorithm design, problem solving, and complexity analysis
【问题讨论】:
-
您使用的是哪个工具? Openpyxl 适用于 Excel。
-
对不起。为了阅读我正在使用的word文件:docx.
-
@Kristof 我已经添加了代码。
-
@BhargavRao 问题不在于输出字符串有 unicode 字符,而是其中有实际的正方形。
-
@SrinivasanA 当你在 Python2 上时,测试这个 Replace non-ASCII characters with a single space 并确认它是否有效。我重新打开了帖子。
标签: python python-2.7 ms-word python-docx