使用python将度符号插入word文档
我使用的是python模块,我只是简单地将学位符号添加到我的word文档中,但看不到如何操作 只要有一个像这样的字符串: Degree=“一些数字:”使用python将度符号插入word文档,python,python-2.7,ms-word,docx,Python,Python 2.7,Ms Word,Docx,我使用的是python模块,我只是简单地将学位符号添加到我的word文档中,但看不到如何操作 只要有一个像这样的字符串: Degree=“一些数字:” 然后我想在我的文档中插入该字符串。我创建了一个空文档,其中包含以下文本: 将其保存为document.docx 将document.docx重命名为document.zip 打开拉链并取出 打开了文件夹word中名为document.xml的文件 这是一个记录word文档结构的链接(信息用途): 以下是document.xml中包含度的特定
然后我想在我的文档中插入该字符串。我创建了一个空文档,其中包含以下文本:
- 将其保存为document.docx
- 将document.docx重命名为document.zip
- 打开拉链并取出
- 打开了文件夹word中名为document.xml的文件
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document mc:Ignorable="w14 wp14" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">
<w:body>
<w:p w:rsidR="009565D8" w:rsidRDefault="00986522">
<w:r>
<w:rPr>
<w:rFonts w:ascii="Arial" w:cs="Arial" w:hAnsi="Arial"/>
<w:color w:val="000000"/>
<w:sz w:val="21"/>
<w:szCs w:val="21"/>
<w:shd w:color="auto" w:fill="FFFFFF" w:val="clear"/>
</w:rPr>
<w:t>12</w:t>
</w:r>
<w:r>
<w:rPr>
<w:rFonts w:ascii="Arial" w:cs="Arial" w:hAnsi="Arial"/>
<w:color w:val="000000"/>
<w:sz w:val="21"/>
<w:szCs w:val="21"/>
<w:shd w:color="auto" w:fill="FFFFFF" w:val="clear"/>
</w:rPr>
<w:t>º</w:t>
</w:r>
<w:bookmarkStart w:id="0" w:name="_GoBack"/>
<w:bookmarkEnd w:id="0"/>
</w:p>
<w:sectPr w:rsidR="009565D8">
<w:pgSz w:h="16838" w:w="11906"/>
<w:pgMar w:bottom="1417" w:footer="708" w:gutter="0" w:header="708" w:left="1417" w:right="1417" w:top="1417"/>
<w:cols w:space="708"/>
<w:docGrid w:linePitch="360"/>
</w:sectPr>
</w:body>
</w:document>
12
º
如您所见,它们是标记:
。这些标记包含文档的文本。其中一个包含12,另一个包含学位符号
所以它只存储为
º
,或charCode 186。要包含您的字符串,请将字符串中学位的字符代码替换为字符代码186,它应该可以工作(例如使用正则表达式)我的答案对您有效吗?不,老实说,我不确定您所说的zip存档是什么意思,打开word/document.xml文件,我无法完成。我已经更新了我的帖子,以更清楚地说明问题。希望这有帮助