我是靠谱客的博主 义气服饰,这篇文章主要介绍python输出word内容_Django输出word文件(.doc),只在内容中显示原始html,现在分享给大家,希望可以做个参考。

除非您有某种方法将您的响应(这里假设为HTML)转换为.doc文件,否则您将得到一个文本文件,其中包含扩展名为.doc的响应。如果您愿意使用.docx文件,那么有一个很棒的python库python-docx您应该看看,它允许您使用lxml库生成格式良好的docx文件。在

或者,使用模板,例如:

@page Section1 {size:595.45pt 841.7pt; margin:1.0in 1.25in 1.0in 1.25in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;}

div.Section1 {page:Section1;}

@page Section2 {size:841.7pt 595.45pt;mso-page-orientation:landscape;margin:1.25in 1.0in 1.25in 1.0in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-paper-source:0;}

div.Section2 {page:Section2;}

'Section1: Portrait, Section2: Landscape

[your text here]

当使用UTF-8字符集作为mime类型application/msword返回时,according to this asp.net forum post应该是一个有效的.doc文件(因此请确保字符串都是unicode)。在

最后

以上就是义气服饰最近收集整理的关于python输出word内容_Django输出word文件(.doc),只在内容中显示原始html的全部内容,更多相关python输出word内容_Django输出word文件(内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(60)

评论列表共有 0 条评论

立即
投稿
返回
顶部