一图看懂 docx 读取、查询、修改 Ms Word docx 文件, 资料整理+笔记(大全)

本文详细探讨了Python的docx模块,涵盖其内部结构,包括opc、compat、shared等子模块,以及Document、ImagePart等类和方法。通过实例解析docx如何读取、查询和修改Word docx文件,帮助开发者更好地理解和操作docx文档。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文由 大侠(AhcaoZhu)原创,转载请声明。
链接: https://blog.csdn.net/Ahcao2008

Alt

一图看懂 docx 读取、查询、修改 Ms Word docx 文件, 资料整理+笔记(大全)

摘要

全文介绍系统内置 python- docx 模块、函数、类及类的方法和属性。
它通过代码抓取并经AI智能翻译和人工校对。
是一部不可多得的权威字典类工具书。它是系列集的一部分。后续陆续发布、敬请关注。【原创:AhcaoZhu大侠】

模块

docx
	docx.opc◎
	docx.compat
	docx.shared
	docx.image◎
	docx.exceptions
	docx.enum◎
	docx.oxml◎
	docx.parts◎
	docx.package
	docx.api
	docx.text◎
	docx.dml◎
	docx.shape
	docx.blkcntnr
	docx.section
	docx.document
	docx.settings
	docx.styles◎
    docx.table??
 ◎--package
 ??--需要单独装载

docx - modules
docx-module

类的关系图

docx-class

◆object
	◆BaseException
		◆Exception
			docx.exceptions.PythonDocxError
				docx.exceptions.InvalidSpanError
				docx.exceptions.InvalidXmlError
	◆collections.abc.Container
		◆collections.abc.Iterable
			◆collections.abc.Sized
				◆collections.abc.Collection
					◆collections.abc.Reversible
						◆collections.abc.Sequence
							docx.section.Sections
	docx.enum.Enumeration
	docx.enum.base.Enumeration
		docx.enum.base.XmlEnumeration
			docx.enum.section.WD_HEADER_FOOTER_INDEX
			docx.enum.section.WD_SECTION_START
			docx.enum.style.WD_STYLE_TYPE
	docx.enum.shape.WD_INLINE_SHAPE_TYPE
	docx.enum.text.WD_BREAK_TYPE
	docx.image.image.BaseImageHeader
		docx.image.bmp.Bmp
		docx.image.gif.Gif
		docx.image.jpeg.Jpeg
			docx.image.jpeg.Exif
			docx.image.jpeg.Jfif
		docx.image.png.Png
		docx.image.tiff.Tiff
	docx.image.image.Image
	docx.opc.constants.CONTENT_TYPE
	docx.opc.constants.RELATIONSHIP_TYPE
	docx.opc.package.OpcPackage
		docx.package.Package
	docx.opc.part.Part
		docx.parts.image.ImagePart
	docx.oxml.simpletypes.BaseSimpleType
		docx.oxml.simpletypes.BaseStringType
			docx.oxml.simpletypes.BaseStringEnumerationType
				docx.oxml.simpletypes.XsdStringEnumeration
					docx.oxml.simpletypes.ST_Merge
	docx.package.ImageParts
	docx.section.Section
	docx.shape.InlineShape
	docx.shared.ElementProxy
		docx.document.Document
		docx.settings.Settings
	docx.shared.Parented
		docx.blkcntnr.BlockItemContainer
			docx.document._Body
			docx.section._BaseHeaderFooter
				docx.section._Footer
				docx.section._Header
			docx.table._Cell
		docx.shape.InlineShapes
		docx.table.Table
		docx.table._Column
		docx.table._Columns
		docx.table._Row
		docx.table._Rows
		docx.text.paragraph.Paragraph
	docx.styles.BabelFish
	◆int
		docx.shared.Length
			docx.shared.Cm
			docx.shared.Emu
			docx.shared.Inches
			docx.shared.Mm
			docx.shared.Pt
			docx.shared.Twips
	◆lxml.etree._Element
		◆lxml.etree.ElementBase
			docx.oxml.xmlchemy.BaseOxmlElement
				docx.oxml.coreprops.CT_CoreProperties
				docx.oxml.document.CT_Body
				docx.oxml.document.CT_Document
				docx.oxml.numbering.CT_Num
				docx.oxml.numbering.CT_NumLvl
				docx.oxml.numbering.CT_NumPr
				docx.oxml.numbering.CT_Numbering
				docx.oxml.section.CT_HdrFtr
				docx.oxml.section.CT_HdrFtrRef
				docx.oxml.section.CT_PageMar
				docx.oxml.section.CT_PageSz
				docx.oxml.section.CT_SectPr
				docx.oxml.section.CT_SectType
				docx.oxml.settings.CT_Settings
				docx.oxml.shape.CT_Blip
				docx.oxml.shape.CT_BlipFillProperties
				docx.oxml.shape.CT_GraphicalObject
				docx.oxml.shape.CT_GraphicalObjectData
				docx.oxml.shape.CT_Inline
				docx.oxml.shape.CT_NonVisualDrawingProps
				docx.oxml.shape.CT_Picture
				docx.oxml.shape.CT_PictureNonVisual
				docx.oxml.shape.CT_Point2D
				docx.oxml.shape.CT_PositiveSize2D
				docx.oxml.shape.CT_ShapeProperties
				docx.oxml.shape.CT_Transform2D
				docx.oxml.shared.CT_DecimalNumber
				docx.oxml.shared.CT_OnOff
				docx.oxml.shared.CT_String
				docx.oxml.styles.CT_LatentStyles
				docx.oxml.styles.CT_LsdException
				docx.oxml.styles.CT_Style
				docx.oxml.styles.CT_Styles
				docx.oxml.table.CT_Height
				docx.oxml.table.CT_Row
				docx.oxml.table.CT_Tbl
				docx.oxml.table.CT_TblGrid
				docx.oxml.table.CT_TblGridCol
				docx.oxml.table.CT_TblLayoutType
				docx.oxml.table.CT_TblPr
				docx.oxml.table.CT_TblWidth
				docx.oxml.table.CT_Tc
				docx.oxml.table.CT_TcPr
				docx.oxml.table.CT_TrPr
				docx.oxml.table.CT_VMerge
				docx.oxml.table.CT_VerticalJc
				docx.oxml.text.font.CT_Color
				docx.oxml.text.font.CT_Fonts
				docx.oxml.text.font.CT_Highlight
				docx.oxml.text.font.CT_HpsMeasure
				docx.oxml.text.font.CT_RPr
				docx.oxml.text.font.CT_Underline
				docx.oxml.text.font.CT_VerticalAlignRun
				docx.oxml.text.paragraph.CT_P
				docx.oxml.text.parfmt.CT_Ind
				docx.oxml.text.parfmt.CT_Jc
				docx.oxml.text.parfmt.CT_PPr
				docx.oxml.text.parfmt.CT_Spacing
				docx.oxml.text.parfmt.CT_TabStop
				docx.oxml.text.parfmt.CT_TabStops
				docx.oxml.text.run.CT_Br
				docx.oxml.text.run.CT_R
				docx.oxml.text.run.CT_Text
	◆str
		docx.opc.packuri.PackURI
		docx.oxml.ns.NamespacePrefixedTag
	◆tuple
		docx.shared.RGBColor
◆-- External class, not in docx module		

模块全展开

统计

序号 类别 数量
4 str 5
6 list 1
8 dict 1
9 module 19
10 class 2
11 function 1
13 residual 3
14 system 10
16 all 32

【docx】

docx, fullname=docx, file=docx_init_.py

常量

模块

1 docx.opc

opc, fullname=docx.opc, file=docx\opc_init_.py

2 docx.compat

compat, fullname=docx.compat, file=docx\compat.py

提供Python 2/3兼容性对象

3 docx.shared

shared, fullname=docx.shared, file=docx\shared.py

docx模块共享的对象。

4 docx.image

image, fullname=docx.image, file=docx\image_init_.py

提供可以根据内容类型和大小来描述图像流的对象,作为在文档中包含它们的必要步骤。

5 docx.exceptions

exceptions, fullname=docx.exceptions, file=docx\exceptions.py

python-docx使用的异常。基异常类是PythonDocxError。

6 docx.enum

enum, fullname=docx.enum, file=docx\enum_init_.py

python-docx中使用的枚举

7 docx.oxml

oxml, fullname=docx.oxml, file=docx\oxml_init_.py

初始化oxml子包,包括注册对应于Open XML元素的自定义元素类。

8 docx.parts

parts, fullname=docx.parts, file=docx\parts_init_.py

9 docx.package

package, fullname=docx.package, file=docx\package.py

Wordprocessing ML Package 包类和相关对象

10 docx.api

api, fullname=docx.api, file=docx\api.py

直接公开API函数和类:func:`Document`。提供一个语法上更方便的API来与OpcPackage图交互。

11 docx.text

text, fullname=docx.text, file=docx\text_init_.py

12 docx.dml

dml, fullname=docx.dml, file=docx\dml_init_.py

13 docx.shape

shape, fullname=docx.shape, file=docx\shape.py

与形状相关的对象,出现在文档的绘图层上的可视对象。

14 docx.blkcntnr

blkcntnr, fullname=docx.blkcntnr, file=docx\blkcntnr.py

块项目容器,用于主体,单元格,标题等。块级项目包括段落和表格,尽管还有其他一些特殊的项目,如结构化文档标记。

15 docx.section

section, fullname=docx.section, file=docx\section.py

|Section|对象和相关的代理类

16 docx.document

document, fullname=docx.document, file=docx\document.py

|Document|及密切相关的对象

17 docx.settings

settings, fullname=docx.settings, file=docx\settings.py

对象,提供对文档级设置的访问

18 docx.styles

styles, fullname=docx.styles, file=docx\styles_init_.py

docx的子包模块,样式子包docx.styles。

19 docx.table

table, fullname=docx.table, file=docx\table.py

|Table|对象和相关的代理类。

函数

20 Document(docx=None)

Document(docx=None), module=docx.api, line:17 at site-packages\docx\api.py

返回一个从 *docx* 加载的|Document|对象,其中*docx*可以是一个``.docx`` 文件(字符串)的路径或一个类文件对象。
如果*docx*缺失或“None”,则加载内置的默认文档“template”。

21 docx.opc.constants.RELATIONSHIP_TYPE

RELATIONSHIP_TYPE, docx.opc.constants.RELATIONSHIP_TYPE, module=docx.opc.constants

data

1 AUDIO kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
2 A_F_CHUNK kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
3 CALC_CHAIN kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
4 CERTIFICATE kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
5 CHART kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
6 CHARTSHEET kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
7 CHART_USER_SHAPES kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
8 COMMENTS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
9 COMMENT_AUTHORS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
10 CONNECTIONS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
11 CONTROL kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
12 CORE_PROPERTIES kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
13 CUSTOM_PROPERTIES kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
14 CUSTOM_PROPERTY kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
15 CUSTOM_XML kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
16 CUSTOM_XML_PROPS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
17 DIAGRAM_COLORS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
18 DIAGRAM_DATA kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
19 DIAGRAM_LAYOUT kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
20 DIAGRAM_QUICK_STYLE kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
21 DIALOGSHEET kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
22 DRAWING kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
23 ENDNOTES kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
24 EXTENDED_PROPERTIES kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
25 EXTERNAL_LINK kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
26 FONT kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
27 FONT_TABLE kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
28 FOOTER kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
29 FOOTNOTES kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
30 GLOSSARY_DOCUMENT kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
31 HANDOUT_MASTER kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
32 HEADER kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
33 HYPERLINK kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
34 IMAGE kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
35 NOTES_MASTER kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
36 NOTES_SLIDE kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
37 NUMBERING kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
38 OFFICE_DOCUMENT kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
39 OLE_OBJECT kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
40 ORIGIN kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
41 PACKAGE kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
42 PIVOT_CACHE_DEFINITION kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
43 PIVOT_CACHE_RECORDS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
44 PIVOT_TABLE kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
45 PRES_PROPS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
46 PRINTER_SETTINGS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
47 QUERY_TABLE kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
48 REVISION_HEADERS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
49 REVISION_LOG kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
50 SETTINGS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
51 SHARED_STRINGS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
52 SHEET_METADATA kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
53 SIGNATURE kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
54 SLIDE kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
55 SLIDE_LAYOUT kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
56 SLIDE_MASTER kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
57 SLIDE_UPDATE_INFO kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
58 STYLES kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
59 TABLE kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
60 TABLE_SINGLE_CELLS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
61 TABLE_STYLES kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
62 TAGS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
63 THEME kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
64 THEME_OVERRIDE kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
65 THUMBNAIL kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
66 USERNAMES kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
67 VIDEO kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
68 VIEW_PROPS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
69 VML_DRAWING kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
70 VOLATILE_DEPENDENCIES kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
71 WEB_SETTINGS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
72 WORKSHEET_SOURCE kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>
73 XML_MAPS kind:data type:str class:<class ‘docx.opc.constants.RELATIONSHIP_TYPE’>

22 docx.parts.image.ImagePart

ImagePart, docx.parts.image.ImagePart, module=docx.parts.image

图像部分。对应关系的目标部分,类型为 RELATIONSHIP_TYPE.IMAGE。

property

1 default_cx=<property object at 0x0000000003B5D1D8> kind:property type:property class:<class ‘docx.parts.image.ImagePart’>
2 default_cy=<property object at 0x0000000003B5D228> kind:property type:property class:<class ‘docx.parts.image.ImagePart’>
3 filename=<property object at 0x0000000003B5D278> kind:property type:property class:<class ‘docx.parts.image.ImagePart’>
4 image=<property object at 0x0000000003B5D2C8> kind:property type:property class:<class ‘docx.parts.image.ImagePart’>
5 sha1=<property object at 0x0000000003B5D318> kind:property type:property class:<class ‘docx.parts.image.ImagePart’>

class method

6 from_image()

kind=class method class=ImagePart objtype=classmethod

classmethod(function) -> method
转换函数为类方法。
类方法接收类作为隐式的第一个参数,就像实例方法接收实例一样。
要声明一个类方法,请使用这个习惯用法:
它可以在类上(例如C.f())或在实例上(例如C().f())被调用。除了它的类,实例将被忽略。
如果为派生类调用类方法,则派生类对象将作为隐含的第一个参数传递。类方法不同于c++或Java的静态方法。
如果你想要这些,请查看内置的staticmethod。

7 load()

kind=class method class=ImagePart objtype=classmethod

统计

序号 类别 数量
4 str 4
6 list 1
8 dict 1
9 module 15
13 residual 3
14 system 9
16 all 24

【docx.opc】

opc, fullname=docx.opc, file=docx\opc_init_.py

模块

1 docx.opc.constants

constants, fullname=docx.opc.constants, file=docx\opc\constants.py

与开放包装公约相关的常量值,特别是内容类型和关系类型。

2 docx.opc.packuri

packuri, fullname=docx.opc.packuri, file=docx\opc\packuri.py

提供PackURI值类型以及一些有用的已知包URI字符串,如 PACKAGE_URI。

3 docx.opc.compat

compat, fullname=docx.opc.compat, file=docx\opc\compat.py

提供Python 2/3兼容性对象

4 docx.opc.oxml

oxml, fullname=docx.opc.oxml, file=docx\opc\oxml.py

PackageReader移植时遇到的主要oxml模块的临时替代品。
可能大部分内容将被来自pptx.oxml.core的对象替换,然后这个模块要么被删除,要么只保存包相关的自定义元素类。

5 docx.opc.rel

rel, fullname=docx.opc.rel, file=docx\opc\rel.py

Relationship-related对象。

6 docx.opc.shared

shared, fullname=docx.opc.shared, file=docx\opc\shared.py

opc模块共享的对象。

7 docx.opc.part

part, fullname=docx.opc.part, file=docx\opc\part.py

与包装部件相关的OPC (Open Packaging Convention)对象。

8 docx.opc.parts

parts, fullname=docx.opc.parts, file=docx\opc\parts_init_.py

9 docx.opc.coreprops

coreprops, fullname=docx.opc.coreprops, file=docx\opc\coreprops.py

:mod:`pptx.packaging` 模块围绕着从.pptx文件中读取和写入演示文稿的关注点。

10 docx.opc.exceptions

exceptions, fullname=docx.opc.exceptions, file=docx\opc\exceptions.py

python-opc特有的异常基异常类是OpcError。

11 docx.opc.phys_pkg

phys_pkg, fullname=docx.opc.phys_pkg, file=docx\opc\phys_pkg.py

提供一个 *physical* OPC包的通用接口,例如zip文件。

12 docx.opc.pkgreader

pkgreader, fullname=docx.opc.pkgreader, file=docx\opc\pkgreader.py

为序列化的开放打包约定(OPC)包提供低级的只读API。
OPC——Open Packaging Convention——开放打包约定

13 docx.opc.spec

spec, fullname=docx.opc.spec, file=docx\opc\spec.py

提供包含开放XML规范ISO/IEC 29500方面的映射。

14 docx.opc.pkgwriter

pkgwriter, fullname=docx.opc.pkgwriter, file=docx\opc\pkgwriter.py

为序列化的开放打包约定(OPC)包提供一个低级的、只写的API,本质上是OpcPackage.save()的实现。

15 docx.opc.package

package, fullname=docx.opc.package, file=docx\opc\package.py

实现读写OPC包的对象。

统计

序号 类别 数量
4 str 5
8 dict 1
9 module 1
10 class 3
11 function 1
13 residual 6
14 system 8
16 all 17

【docx.compat】

compat, fullname=docx.compat, file=docx\compat.py

提供Python 2/3兼容性对象

模块

1 sys

sys, fullname=sys, file=

这个模块提供了对解释器使用或维护的一些对象的访问,以及对与解释器强烈交互的函数的访问。
参见:sys 模块。

函数

2 is_string(obj)

is_string(obj), module=docx.compat, line:20 at site-packages\docx\compat.py

如果*obj*是字符串则返回True,否则返回False。

3 collections.abc.Sequence

Sequence, collections.abc.Sequence, module=collections.abc, line:-1 at collections\abc.py

对只读序列的所有操作。具体的子类必须重写 __new__ 或 __init__, __getitem__, 和 __len__.

method

1 count()

kind=method class=Sequence objtype=function

S.count(value) -> integer -返回值的出现次数

2 index()

kind=method class=Sequence objtype=function

S.index(value, [start, [stop]]) -> integer -返回值的第一个索引。
如果值不存在则引发ValueError。支持start和stop参数是可选的,但推荐使用。

4 _io.BytesIO

BytesIO, _io.BytesIO, module=_io

使用内存字节缓冲区的缓冲I/O实现。

data

1 closed=<attribute ‘closed’ of ‘_io.BytesIO’ objects> kind:data type:getset_descriptor class:<class ‘_io.BytesIO’>

method

2 close(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:772 at …-1026899380_io.py

禁用所有I/O操作。

3 flush(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:776 at …-1026899380_io.py

什么也不做。

4 getbuffer(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:780 at …-1026899380_io.py

获取BytesIO对象内容的读写视图。

5 getvalue(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:784 at …-1026899380_io.py

检索BytesIO对象的全部内容。

6 isatty(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:788 at …-1026899380_io.py

总是返回False。BytesIO对象没有连接到类似tty的设备。

7 read(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:796 at …-1026899380_io.py

读取最多大小字节,作为bytes对象返回。如果size参数为负,则读取直到到达EOF。在EOF处返回一个空字节对象。

8 read1(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:805 at …-1026899380_io.py

读取最多大小字节,作为bytes对象返回。如果size参数为负或省略,则读取直到到达EOF。在EOF处返回一个空字节对象。

9 readable(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:814 at …-1026899380_io.py

如果IO对象可以读取,则返回True。

10 readinto(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:818 at …-1026899380_io.py

将字节读入缓冲区。返回读取的字节数(EOF为0),如果对象设置为不阻塞且没有数据要读取,则返回None。

11 readline(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:827 at …-1026899380_io.py

文件中的下一行,作为一个字节对象。保留换行符。非负的size参数限制要返回的最大字节数(这时可能返回不完整的行)。在EOF处返回一个空字节对象。

12 readlines(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:837 at …-1026899380_io.py

bytes对象列表,每一行从文件开始。反复调用readline()并返回已读取的行列表。如果给出可选的size参数,则是返回行的总字节数的近似边界。

13 seek(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:847 at …-1026899380_io.py

改变流位置。参见 io 模块。

14 seekable(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:859 at …-1026899380_io.py

如果IO对象可以被查找,则返回True。

15 tell(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:863 at …-1026899380_io.py

参见 io 模块。

16 truncate(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:867 at …-1026899380_io.py

将文件截断为最多字节大小。Size默认为当前文件位置,由tell()返回。当前文件位置不变。返回新的大小。

17 writable(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:876 at …-1026899380_io.py

如果IO对象可以写入,则返回True。

18 write(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:880 at …-1026899380_io.py

将字节写入文件。返回写入的字节数。

19 writelines(self, *args, **kwargs)

kind=method class=BytesIO objtype=method_descriptor line:888 at …-1026899380_io.py

向文件中写入行。注意,没有添加换行符。行可以是任何产生字节类对象的可迭代对象。这相当于为每个元素调用write()。

5 str

str, str, module=builtins

str(object=) -> str str(bytes or buffer[, encoding[, errors]]) -> str
从给定对象中创建一个新的字符串对象。参见:str

method

1 capitalize()

kind=method class=str objtype=method_descriptor

返回字符串的大写版本。更具体地说,使第一个字符大写,其余字符小写。

2 casefold()

kind=method class=str objtype=method_descriptor

返回适合于无大小写比较的字符串版本。

3 center()

kind=method class=str objtype=method_descriptor

返回长度为width的居中字符串。填充使用指定的填充字符(默认为空格)。

4 count()

kind=method class=str objtype=method_descriptor

S.count(sub[, start[, end]]) -> int
返回子字符串sub在字符串S[start:end]中不重叠出现的次数。可选参数start和end被解释为片表示法。

5 encode()

kind=method class=str objtype=method_descriptor

使用为编码注册的编解码器对字符串进行编码。encoding对字符串进行编码的编码。
用于编码错误的错误处理方案。默认值是'strict',这意味着编码错误会引发UnicodeEncodeError。
其他可能的值是'ignore', 'replace'和'xmlcharrefreplace'以及任何其他用编解码器注册的名称。寄存器错误,可以处理UnicodeEncodeErrors。

6 endswith()

kind=method class=str objtype=method_descriptor

S.endswith(suffix[, start[, end]]) -> bool
如果S以指定后缀结束则返回True,否则返回False。使用可选启动,测试S从该位置开始。
使用可选结束,在该位置停止比较S。Suffix也可以是字符串的元组来尝试。

7 expandtabs()

kind=method class=str objtype=method_descriptor

返回一个副本,其中所有制表符都使用空格展开。如果没有给出tabsize,则假定制表符大小为8个字符。

8 find()

kind=method class=str objtype=method_descriptor

S.find(sub[, start[, end]]) -> int
返回S中找到子字符串sub的最低索引,使sub包含在S[start:end]中。可选参数start和end被解释为片表示法。失败时返回-1。

9 format()

kind=method class=str objtype=method_descriptor

S.format(*args, **kwargs) -> str
返回S的格式化版本,使用args和kwargs的替换。替换由大括号('{'和'}')标识。

10 format_map()

kind=method class=str objtype=method_descriptor

S.format map(mapping) -> str
返回S的格式化版本,使用mapping中的替换。替换由大括号('{'和'}')标识。

11 index()

kind=method class=str objtype=method_descriptor

S.index(sub[, start[, end]]) -> int
返回S中子串sub所在位置的最低索引,使sub包含在S[start:end]中。可选参数start和end被解释为片表示法。当子字符串未找到时引发ValueError。

12 isalnum()

kind=method class=str objtype=method_descriptor

如果字符串是字母-数字字符串则返回True,否则返回False。如果字符串中的所有字符都是字母-数字,并且字符串中至少有一个字符,则字符串为字母-数字。

13 isalpha()

kind=method class=str objtype=method_descriptor

如果字符串是字母字符串则返回True,否则返回False。如果字符串中的所有字符都是字母,并且字符串中至少有一个字符,则字符串为字母字符串。

14 isascii()

kind=method class=str objtype=method_descriptor

如果字符串中的所有字符都是ASCII,则返回True,否则返回False。ASCII字符的码位范围为U+0000-U+007F。空字符串也是ASCII。

15 isdecimal()

kind=method class=str objtype=method_descriptor

如果字符串是十进制字符串则返回True,否则返回False。如果字符串中的所有字符都是十进制,并且字符串中至少有一个字符,则字符串是十进制字符串。

16 isdigit()

kind=method class=str objtype=method_descriptor

如果字符串是数字字符串则返回True,否则返回False。如果字符串中的所有字符都是数字,并且字符串中至少有一个字符,则字符串是数字字符串。

17 isidentifier()

kind=method class=str objtype=method_descriptor

如果字符串是有效的Python标识符,则返回True,否则返回False。使用keyword.iskeyword()测试保留的标识符,如“def”和“class”。

18 islower()

kind=method class=str objtype=method_descriptor

如果字符串是小写字符串则返回True,否则返回False。如果字符串中所有的分大小写字符都是小写的,并且字符串中至少有一个分大小写字符,则字符串是小写的。

19 isnumeric()

kind=method class=str objtype=method_descriptor

如果字符串是数字字符串则返回True,否则返回False。如果字符串中的所有字符都是数字,并且字符串中至少有一个字符,则字符串为数字。

20 isprintable()

kind=method class=str objtype=method_descriptor

如果字符串是可打印的返回True,否则返回False。如果一个字符串的所有字符在repr()中都被认为是可打印的,或者字符串为空,则该字符串是可打印的。

21 isspace()

kind=method class=str objtype=method_descriptor

如果字符串是空白字符串则返回True,否则返回False。如果字符串中所有字符都是空白,并且字符串中至少有一个字符,则字符串为空白。

22 istitle()

kind=method class=str objtype=method_descriptor

如果字符串是标题大小写字符串,则返回True,否则返回False。在标题大小写字符串中,大写字符和标题大小写字符只能跟在无大小写字符后面,小写字符只能跟在有大小写字符后面。

23 isupper()

kind=method class=str objtype=method_descriptor

如果字符串是大写字串则返回True,否则返回False。如果字符串中所有的大小写字符都是大写字符,并且字符串中至少有一个大小写字符,则字符串为大写字符。

24 join()

kind=method class=str objtype=method_descriptor

Example: '.'.join(['ab', 'pq', 'rs']) -> 'ab.pq.rs'

25 ljust()

kind=method class=str objtype=method_descriptor

返回一个长度为width的左对齐字符串。填充使用指定的填充字符(默认为空格)。

26 lower()

kind=method class=str objtype=method_descriptor

返回一个转换成小写字母的字符串副本。

27 lstrip()

kind=method class=str objtype=method_descriptor

返回删除前导空格的字符串副本。如果给出了chars而不是None,则改为删除chars中的字符。

28 partition()

kind=method class=str objtype=method_descriptor

使用给定的分隔符将字符串分成三部分。这将搜索字符串中的分隔符。如果找到分隔符,则返回一个3元组,其中包含分隔符之前的部分、分隔符本身和分隔符之后的部分。如果分隔符未找到,则返回一个包含原始字符串和两个空字符串的3元组。

29 replace()

kind=method class=str objtype=method_descriptor

返回一个副本,将所有出现的子字符串old替换为new。count最大替换次数。-1(默认值)表示替换所有出现的情况。
如果给出了可选参数count,则只替换第一次出现的计数。

30 rfind()

kind=method class=str objtype=method_descriptor

S.rfind(sub[, start[, end]]) -> int
返回S中子字符串sub所在位置的最高索引,使sub包含在S[start:end]中。可选参数start和end被解释为片表示法。失败时返回-1。

31 rindex()

kind=method class=str objtype=method_descriptor

S.rindex(sub[, start[, end]]) -> int
返回S中子串sub所在位置的最高索引,使sub包含在S[start:end]中。可选参数start和end被解释为片表示法。当子字符串未找到时引发ValueError。

32 rjust()

kind=method class=str objtype=method_descriptor

返回一个长度为width的右对齐字符串。填充使用指定的填充字符(默认为空格)。

33 rpartition()

kind=method class=str objtype=method_descriptor

使用给定的分隔符将字符串分成三部分。这将搜索字符串中的分隔符,从末尾开始。
如果找到分隔符,则返回一个3元组,其中包含分隔符之前的部分、分隔符本身和分隔符之后的部分。如果分隔符未找到,则返回包含两个空字符串和原始字符串的3元组。

34 rsplit()

kind=method class=str objtype=method_descriptor

返回字符串中的单词列表,使用sep作为分隔符字符串。sep分隔符,用于分隔字符串。None(默认值)表示根据任何空白进行分割,并丢弃结果中的空字符串。
maxsplit最大拆分次数。-1(默认值)表示没有限制。劈叉是从弦的末端开始,一直到前面。

35 rstrip()

kind=method class=str objtype=method_descriptor

返回一个删除了尾随空格的字符串副本。如果给出了chars而不是None,则改为删除chars中的字符。

36 split()

kind=method class=str objtype=method_descriptor

返回字符串中的单词列表,使用sep作为分隔符字符串。sep分隔符,用于分隔字符串。
None(默认值)表示根据任何空白进行分割,并丢弃结果中的空字符串。maxsplit最大拆分次数。-1(默认值)表示没有限制。

37 splitlines()

kind=method class=str objtype=method_descriptor

返回字符串中的行列表,在行边界处断行。结果列表中不包括换行符,除非给出keepends并为true。

38 startswith()

kind=method class=str objtype=method_descriptor

S.startswith(prefix[, start[, end]]) -> bool
如果S以指定的前缀开始返回True,否则返回False。使用可选启动,测试S从该位置开始。使用可选结束,在该位置停止比较S。前缀也可以是字符串的元组来尝试。

39 strip()

kind=method class=str objtype=method_descriptor

返回删除前导和尾随空格的字符串副本。如果给出了chars而不是None,则改为删除chars中的字符。

40 swapcase()

kind=method class=str objtype=method_descriptor

将大写字符转换为小写字符,将小写字符转换为大写字符。

41 title()

kind=method class=str objtype=method_descriptor

返回字符串的一个版本,其中每个单词都有标题。更具体地说,单词以大写字符开头,其余的大小写字符都是小写字符。

42 translate()

kind=method class=str objtype=method_descriptor

使用给定的转换表替换字符串中的每个字符。table转换表,必须是Unicode序数到Unicode序数、字符串或None的映射。
表必须通过getitem实现查找/索引,例如字典或列表。如果此操作引发LookupError,则该字符将保持不变。映射为None的字符将被删除。

43 upper()

kind=method class=str objtype=method_descriptor

返回一个转换为大写字母的字符串副本。

44 zfill()

kind=method class=str objtype=method_descriptor

填充数字字符串左侧的零,以填充给定宽度的字段。字符串永远不会被截断。

static method

45 maketrans()

kind=static method class=str objtype=staticmethod

剩余

6 loader <_frozen_importlib_external.SourceFileLoader object at 0x0000000003928708>
7 spec ModuleSpec(name=‘docx.compat’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x0000000003928708>, origin=‘…\lib\site-packages\docx\compat.py’)
8 absolute_import _Feature((2, 5, 0, ‘alpha’, 1), (3, 0, 0, ‘alpha’, 0), 16384)
9 division _Feature((2, 2, 0, ‘alpha’, 2), (3, 0, 0, ‘alpha’, 0), 8192)
10 print_function _Feature((2, 6, 0, ‘alpha’, 2), (3, 0, 0, ‘alpha’, 0), 65536)
11 unicode_literals _Feature((2, 6, 0, ‘alpha’, 2), (3, 0, 0, ‘alpha’, 0), 131072)

统计

序号 类别 数量
4 str 5
8 dict 1
10 class 10
11 function 2
13 residual 5
14 system 8
16 all 23

【docx.shared】

shared, fullname=docx.shared, file=docx\shared.py

docx模块共享的对象。

函数

1 lazyproperty(f)

lazyproperty(f), module=docx.shared, line:158 at site-packages\docx\shared.py

@lazyprop装饰器。
方法将只在第一次访问时调用,以计算缓存的属性值。之后,返回缓存的值。

2 write_only_property(f)

write_only_property(f), module=docx.shared, line:178 at site-packages\docx\shared.py

只写属性装饰器。创建接受赋值的属性(描述符属性),但不接受getattr(在表达式中使用)。

3 docx.shared.Length

Length, docx.shared.Length, module=docx.shared

长度构造函数类Inch、Cm、Mm、Px和Emu的基类。表现为英制公制单位的int计数,英寸为914,400,毫米为36,000。
以只读属性的形式提供方便的单位转换方法。不可变的。

property

1 cm=<property object at 0x000000000392ADB8> kind:property type:property class:<class ‘docx.shared.Length’>
2 emu=<property object at 0x000000000392AE08> kind:property type:property class:<class ‘docx.shared.Length’>
3 inches=<property object at 0x000000000392AE58> kind:property type:property class:<class ‘docx.shared.Length’>
4 mm=<property object at 0x000000000392AEA8> kind:property type:property class:<class ‘docx.shared.Length’>
5 pt=<property object at 0x000000000392AEF8> kind:property type:property class:<class ‘docx.shared.Length’>
6 twips=<property object at 0x000000000392AF48> kind:property type:property class:<class ‘docx.shared.Length’>

4 docx.shared.Inches

Inches, docx.shared.Inches, module=docx.shared

以英寸为单位的长度方便构造函数,例如。``width = Inches(0.5)``。

5 docx.shared.Cm

Cm, docx.shared.Cm, module=docx.shared

以厘米为单位的方便构造函数,例如。``height = Cm(12)``。

6 docx.shared.Emu

Emu, docx.shared.Emu, module=docx.shared

长度的英文公制单位的方便构造函数,例如。``width = Emu(457200)``。

7 docx.shared.Mm

Mm, docx.shared.Mm, module=docx.shared

以毫米为单位的长度方便构造函数,例如。``width = Mm(240.5)``。

8 docx.shared.Pt

Pt, docx.shared.Pt, module=docx.shared

方便值类,用于指定以点为单位的长度

9 docx.shared.Twips

Twips, docx.shared.Twips, module=docx.shared

长度单位为twips的方便构造函数,例如 ``width = Twips(42)``。twip是二十分之一点,635 EMU。

10 docx.shared.RGBColor

RGBColor, docx.shared.RGBColor, module=docx.shared

定义特定RGB颜色的不可变值对象。

class method

1 from_string()

kind=class method class=RGBColor objtype=classmethod

11 docx.shared.ElementProxy

ElementProxy, docx.shared.ElementProxy, module=docx.shared

lxml元素代理类的基类。元素代理类的主要职责是操作XML元素的属性和子元素。它们是python-docx中除了自定义元素(oxml)类之外最常见类的类型。

property

1 element=<property object at 0x00000000039319A8> kind:property type:property class:<class ‘docx.shared.ElementProxy’>
2 part=<property object at 0x00000000039319F8> kind:property type:property class:<class ‘docx.shared.ElementProxy’>

12 docx.shared.Parented

Parented, docx.shared.Parented, module=docx.shared

为部分下面出现的文档元素提供公共服务,但偶尔可能需要一个祖先对象来提供服务,例如添加或删除关系。提供了``self._parent``属性给子类。

property

1 part=<property object at 0x0000000003931B88> kind:property type:property class:<class ‘docx.shared.Parented’>

剩余

13 loader <_frozen_importlib_external.SourceFileLoader object at 0x0000000003928A08>
14 spec ModuleSpec(name=‘docx.shared’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x0000000003928A08>, origin=‘…\lib\site-packages\docx\shared.py’)
15 absolute_import _Feature((2, 5, 0, ‘alpha’, 1), (3, 0, 0, ‘alpha’, 0), 16384)
16 print_function _Feature((2, 6, 0, ‘alpha’, 2), (3, 0, 0, ‘alpha’, 0), 65536)
17 unicode_literals _Feature((2, 6, 0, ‘alpha’, 2), (3, 0, 0, ‘alpha’, 0), 131072)

统计

序号 类别 数量
4 str 5
5 tuple 1
6 list 1
8 dict 1
9 module 9
10 class 6
13 residual 6
14 system 9
16 all 29

【docx.image】

image, fullname=docx.image, file=docx\image_init_.py

提供可以将图像流描述为内容类型和对象大小,作为在文档中包含它们的必要步骤。

常量

tuple

1 SIGNATURES ((<class ‘docx.image.png.Png’>, 0, b’\x89PNG\r\n\x1a\n’), (<class 'docx.image.jp…

模块

2 docx.image.constants

constants, fullname=docx.image.constants, file=docx\image\constants.py

特定于图像子包的常量

3 docx.image.exceptions

exceptions, fullname=docx.image.exceptions, file=docx\image\exceptions.py

特定于映像子包的异常

4 docx.image.helpers

helpers, fullname=docx.image.helpers, file=docx\image\helpers.py

5 docx.image.image

image, fullname=docx.image.image, file=docx\image\image.py

提供可以根据内容类型和大小来描述图像流的对象,作为在文档中包含它们的必要步骤。

6 docx.image.bmp

bmp, fullname=docx.image.bmp, file=docx\image\bmp.py

7 docx.image.gif

gif, fullname=docx.image.gif, file=docx\image\gif.py

8 docx.image.tiff

tiff, fullname=docx.image.tiff, file=docx\image\tiff.py

9 docx.image.jpeg

jpeg, fullname=docx.image.jpeg, file=docx\image\jpeg.py

与JPEG图像流的解析头相关的对象,包括JFIF和Exif子格式。

10 docx.image.png

png, fullname=docx.image.png, file=docx\image\png.py

11 docx.image.bmp.Bmp

Bmp, docx.image.bmp.Bmp, module=docx.image.bmp

BMP图像的图像头解析器

property

1 content_type=<property object at 0x0000000003923A98> kind:property type:property class:<class ‘docx.image.bmp.Bmp’>
2 default_ext=<property object at 0x0000000003935458> kind:property type:property class:<class ‘docx.image.bmp.Bmp’>

class method

3 from_stream()

kind=class method class=Bmp objtype=classmethod

12 docx.image.gif.Gif

Gif, docx.image.gif.Gif, module=docx.image.gif

GIF图像的图像头解析器。注意,GIF格式不支持分辨率(DPI)信息。水平和垂直DPI默认为72。

property

1 content_type=<property object at 0x0000000003935778> kind:property type:property class:<class ‘docx.image.gif.Gif’>
2 default_ext=<property object at 0x00000000039357C8> kind:property type:property class:<class ‘docx.image.gif.Gif’>

class method

3 from_stream()

kind=class method class=Gif objtype=classmethod

13 docx.image.jpeg.Exif

Exif, docx.image.jpeg.Exif, module=docx.image.jpeg

用于Exif图像格式的图像头解析器

class method

1 from_stream()

kind=class method class=Exif objtype=classmethod

14 docx.image.jpeg.Jfif

Jfif, docx.image.jpeg.Jfif, module=docx.image.jpeg

图像头解析器用于JFIF图像格式

class method

1 from_stream()

kind=class method class=Jfif objtype=classmethod

15 docx.image.png.Png

Png, docx.image.png.Png, module=docx.image.png

PNG图像的图像头解析器

property

1 content_type=<property object at 0x0000000003951CC8> kind:property type:property class:<class ‘docx.image.png.Png’>
2 default_ext=<property object at 0x0000000003951D18> kind:property type:property class:<class ‘docx.image.png.Png’>

class method

3 from_stream()

kind=class method class=Png objtype=classmethod

16 docx.image.tiff.Tiff

Tiff, docx.image.tiff.Tiff, module=docx.image.tiff

TIFF图像的图像头解析器。处理大端和小端字节排序。

property

1 content_type=<property object at 0x0000000003943AE8> kind:property type:property class:<class ‘docx.image.tiff.Tiff’>
2 default_ext=<property object at 0x0000000003943B38> kind:property type:property class:<class ‘docx.image.tiff.Tiff’>

class method

3 from_stream()

kind=class method class=Tiff objtype=classmethod

剩余

17 loader <_frozen_importlib_external.SourceFileLoader object at 0x0000000003914FC8>
18 spec ModuleSpec(name=‘docx.image’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x0000000003914FC8>, origin=‘…\lib\site-packages\docx\image\init.py’, submodule_search_locations=[‘…\lib\site-packages\docx\image’])
19 absolute_import _Feature((2, 5, 0, ‘alpha’, 1), (3, 0, 0, ‘alpha’, 0), 16384)
20 division _Feature((2, 2, 0, ‘alpha’, 2), (3, 0, 0, ‘alpha’, 0), 8192)
21 print_function _Feature((2, 6, 0, ‘alpha’, 2), (3, 0, 0, ‘alpha’, 0), 65536)
22 unicode_literals _Feature((2, 6, 0, ‘alpha’, 2), (3, 0, 0, ‘alpha’, 0), 131072)

统计

序号 类别 数量
4 str 5
8 dict 1
10 class 3
13 residual 2
14 system 8
16 all 11

【docx.exceptions】

exceptions, fullname=docx.exceptions, file=docx\exceptions.py

python-docx使用的异常。基异常类是PythonDocxError。

1 docx.exceptions.PythonDocxError

PythonDocxError, docx.exceptions.PythonDocxError, module=docx.exceptions

泛型错误类。

2 docx.exceptions.InvalidSpanError

InvalidSpanError, docx.exceptions.InvalidSpanError, module=docx.exceptions

在合并表单元格的请求中指定无效的合并区域时将被引发。

3 docx.exceptions.InvalidXmlError

InvalidXmlError, docx.exceptions.InvalidXmlError, module=docx.exceptions

当遇到无效的XML时将被引发,例如试图访问缺少的必需子元素

统计

序号 类别 数量
4 str 5
6 list 1
8 dict 1
9 module 7
10 class 1
13 residual 5
14 system 9
16 all 20

【docx.enum】

enum, fullname=docx.enum, file=docx\enum_init_.py

python-docx中使用的枚举

模块

1 docx.enum.base

base, fullname=docx.enum.base, file=docx\enum\base.py

枚举使用的基类和其他对象

2 docx.enum.section

section, fullname=docx.enum.section, file=docx\enum\section.py

在WordprocessingML文件中与主文档相关的枚举

3 docx.enum.style

style, fullname=docx.enum.style, file=docx\enum\style.py

与样式相关的枚举

4 docx.enum.table

table, fullname=docx.enum.table, file=docx\enum\table.py

与WordprocessingML文件中的表相关的枚举

5 docx.enum.dml

dml, fullname=docx.enum.dml, file=docx\enum\dml.py

DrawingML对象使用的枚举

6 docx.enum.text

text, fullname=docx.enum.text, file=docx\enum\text.py

与WordprocessingML文件中的文本相关的枚举

7 docx.enum.shape

shape, fullname=docx.enum.shape, file=docx\enum\shape.py

在WordprocessingML文件中与DrawingML形状相关的枚举

8 docx.enum.Enumeration

Enumeration, docx.enum.Enumeration, module=docx.enum

class method

1 from_xml()

kind=class method class=Enumeration objtype=classmethod

2 to_xml()

kind=class method class=Enumeration objtype=classmethod

剩余

9 loader <_frozen_importlib_external.SourceFileLoader object at 0x0000000003A5D5C8>
10 spec ModuleSpec(name=‘docx.enum’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x0000000003A5D5C8>, origin=‘…\lib\site-packages\docx\enum\init.py’, submodule_search_locations=[‘…\li

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AhcaoZhu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值