Python:将json+html字符串转换为.d

2024-09-24 22:25:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在编写一个python脚本,我必须将一个呈现的字符串(从json中包含html)转换为一个.docx文件。 我在网上查了很多,但还是搞不懂。 我试过使用python docx,但效果不佳,因为需要docx输入,而他不喜欢将此作为字符串:

<h1><span lessico='Questa' idx="0" testo="testo" show-modal="setModal()"     tables="updateTables(input)">Questa</span> <span lessico='&egrave;' idx="1" testo="testo" show-modal="setModal()" tables="updateTables(input)">&egrave;</span> <span lessico='una' idx="2" testo="testo" show-modal="setModal()" tables="updateTables(input)">una</span> <span lessico='domanda' idx="3" testo="testo" show-modal="setModal()" tables="updateTables(input)">domanda</span>...</h1>

<ul>

 <li>a scelta multipla</li>

 <li>con risposta aperta</li>

 <li>di tipo trova</li>

 <li>di associazione</li>

如何将其转换为格式化的.doc或.docx?可能不会生气:)


Tags: 字符串inputtablesshowlih1spandocx