我是靠谱客的博主 义气服饰,最近开发中收集的这篇文章主要介绍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文件(.doc),只在内容中显示原始html所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部