我试图显示divs取决于是否已进行数据库输入:
<table class="info-table">
<tr><td>
<div class="info-table_titlebox">
{% if post.wrk_1_title is defined %}
<div class="info-title_title">
<h2>{{post.wrk_1_title}}</h2>
<h3>Facilitator: {{post.wrk_1_facilitator}}</h3>
<h4>Location: {{post.wrk_1_locate}}</h4>
<h4>Max participants: {{post.wrk_1_max}}</h4>
</div>
<div class="info-title_list">
<ul>
<li>{{post.eventday}} - <b>Week {{post.eventweek}}</b></li>
<li class="info-title_listright">{{post.wrk_1_time}}</li>
</ul>
</div>
<p>{{post.wrk_1_description}}</p>
{% endif %}
</div>
</td>
<td>
<div class="info-table_titlebox">
{% if post.wrk_1_title is defined and post.wrk_2_title is defined %}
<div class="info-title_title">
<h2>{{post.wrk_2_title}}</h2>
<h3>Facilitator: {{post.wrk_2_facilitator}}</h3>
<h4>Location: {{post.wrk_2_locate}}</h4>
<h4>Max participants: {{post.wrk_2_max}}</h4>
</div>
<div class="info-title_list">
<ul>
<li>{{post.eventday}} - <b>Week {{post.eventweek}}</b></li>
<li class="info-title_listright">{{post.wrk_2_time}}</li>
</ul>
</div>
<p>{{post.wrk_2_description}}</p>
{% endif …Run Code Online (Sandbox Code Playgroud) 以下代码尝试使用landscape方向,但文档创建为potrait.
可以建议问题出在哪里?
from docx import Document
from docx.enum.section import WD_ORIENT
document = Document()
section = document.sections[-1]
section.orientation = WD_ORIENT.LANDSCAPE
document.add_heading('text')
document.save('demo.docx')
Run Code Online (Sandbox Code Playgroud)
当我以XML格式读回代码时
<w:document>
<w:body>
<w:p>
<w:pPr>
<w:pStyle w:val="Heading1"/>
</w:pPr>
<w:r>
<w:t>TEXT</w:t>
</w:r>
</w:p>
<w:sectPr w:rsidR="00FC693F" w:rsidRPr="0006063C" w:rsidSect="00034616">
<w:pgSz w:w="12240" w:h="15840" w:orient="landscape"/>
<w:pgMar w:top="1440" w:right="1800" w:bottom="1440" w:left="1800" w:header="720" w:footer="720" w:gutter="0"/>
<w:cols w:space="720"/>
<w:docGrid w:linePitch="360"/>
</w:sectPr>
</w:body>
</w:document>
Run Code Online (Sandbox Code Playgroud)
假设部分标签应该位于顶部而不是底部的TEXT标签之上,我不太清楚XML.