使用 python-docx 读取 .docx,保留特殊字符、项目符号
Using python-docx to to read .docx, preserving special characters, bullets
我正在尝试在 python.
中批量处理许多 .docx 格式的 Microsoft Word 文档
下面的代码完成了我需要的,除了它丢失了我想保留的特殊字符,比如右箭头符号和项目符号。
import docx
def getText(filename):
doc = docx.Document(filename)
fullText = []
for para in doc.paragraphs:
fullText.append(para.text)
return fullText
getText('example.docx')
Paragraph.text
属性 in python-pptx
returns 段落中的纯文本作为字符串。这是一个很常见的要求。
项目符号或一般的编号列表(项目符号是其中的一种)不会反映在段落的文本中,即使它可能在屏幕上以这种方式出现。这种事情将是段落的附加属性。
可以应用项目符号的一种方法是使用 'List Bullet' 样式。段落样式在 Paragraph.style
.
上可用
此处的文档是您了解此内容和其他详细信息的朋友,尤其是用户指南部分中的 11 个主题:
http://python-docx.readthedocs.io/en/latest/
我正在尝试在 python.
中批量处理许多 .docx 格式的 Microsoft Word 文档下面的代码完成了我需要的,除了它丢失了我想保留的特殊字符,比如右箭头符号和项目符号。
import docx
def getText(filename):
doc = docx.Document(filename)
fullText = []
for para in doc.paragraphs:
fullText.append(para.text)
return fullText
getText('example.docx')
Paragraph.text
属性 in python-pptx
returns 段落中的纯文本作为字符串。这是一个很常见的要求。
项目符号或一般的编号列表(项目符号是其中的一种)不会反映在段落的文本中,即使它可能在屏幕上以这种方式出现。这种事情将是段落的附加属性。
可以应用项目符号的一种方法是使用 'List Bullet' 样式。段落样式在 Paragraph.style
.
此处的文档是您了解此内容和其他详细信息的朋友,尤其是用户指南部分中的 11 个主题:
http://python-docx.readthedocs.io/en/latest/