[英]Inserting the degree symbol into the word document using python
I am using the python https://github.com/mikemaccana/python-docx module and I am trying to just simply add the degree symbol to my word document and can not see how to do it. 我正在使用python https://github.com/mikemaccana/python-docx模块,并且我试图仅将度数符号添加到我的Word文档中,而看不到如何做。
Just have a string something like this: 只需要一个类似这样的字符串:
Degree = "some_numberº" 度=“some_numberº”
and then I want to insert that string in my document. 然后我要在我的文档中插入该字符串。
I have created an empty document with the following text inside it: 我创建了一个空文档,其中包含以下文本:
This is a link documenting the structure of a word document 'of information purposes) : https://stackoverflow.com/tags/docx/info 这是一个记录单词文档结构的链接,用于信息目的): https : //stackoverflow.com/tags/docx/info
Here's the content of the document.xml for the specific file with degrees inside: 这是内部带有度数的特定文件的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>
As you can see, they are tags: <w:t></w:t>
. 如您所见,它们是标记:
<w:t></w:t>
。 These tags contain the text of your document. 这些标记包含文档的文本。 One of them contains 12 , and the other contains the degree symbol.
其中一个包含12 ,另一个包含度数符号。
So it is just stored as º
, or charCode 186. To include your string, replace the charactercode of the degree in the string by the characterCode 186, it should work (with a regex for example) 因此,它只是存储为
º
或charCode186。要包括您的字符串,请用characterCode 186替换字符串中度数的字符代码,它应该可以工作(例如使用正则表达式)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.