当前位置: 首页 > news >正文

贵阳论坛网站建设网站设计目的与规划怎么写

贵阳论坛网站建设,网站设计目的与规划怎么写,浏览器网页截图快捷键,域名防红短链接生成Python处理word文件,一般都是推荐的Python-docx,但是只写出一个,一句话的文件,也没有什么样式,就是36K。 再打开word在另存一下,就可以到7-8k,我想一定是python-docx的问题,但一直没…

Python处理word文件,一般都是推荐的Python-docx,但是只写出一个,一句话的文件,也没有什么样式,就是36K。

再打开word在另存一下,就可以到7-8k,我想一定是python-docx的问题,但一直没有找到优化方案

这是python-docx生成的文件

from docx import Document# 创建一个新的Word文档
document = Document()# 添加一个段落
document.add_paragraph('Hello, World!')# 保存文档
document.save('hello_world.docx')

最后找到了另外一个模块Spire.Doc,极致丝滑,生成的文件只有7-8k,

模块应该很低调,没见太多人推荐

pip install Spire.Doc

这是Spire.Doc生成的文件,官方的例子写入文件的大概操作都比较全了,而且文字数量,明显是字符多于上面的,但大小7-8k,一整个压缩下来了。

这是文档地址:Python: Create, Read, or Update a Word Document

from spire.doc import *	
from spire.doc.common import *# Create a Document object
doc = Document()# Add a section
section = doc.AddSection()# Set the page margins
section.PageSetup.Margins.All = 40# Add a title
titleParagraph = section.AddParagraph()
titleParagraph.AppendText("Introduction of Spire.Doc for Python")# Add two paragraphs
bodyParagraph_1 = section.AddParagraph()
bodyParagraph_1.AppendText("Spire.Doc for Python is a professional Python library designed for developers to " +"create, read, write, convert, compare and print Word documents in any Python application " +"with fast and high-quality performance.")bodyParagraph_2 = section.AddParagraph()
bodyParagraph_2.AppendText("As an independent Word Python API, Spire.Doc for Python doesn't need Microsoft Word to " +"be installed on neither the development nor target systems. However, it can incorporate Microsoft Word " +"document creation capabilities into any developers' Python applications.")# Apply heading1 to the title
titleParagraph.ApplyStyle(BuiltinStyle.Heading1)# Create a style for the paragraphs
style2 = ParagraphStyle(doc)
style2.Name = "paraStyle"
style2.CharacterFormat.FontName = "Arial"
style2.CharacterFormat.FontSize = 13
doc.Styles.Add(style2)
bodyParagraph_1.ApplyStyle("paraStyle")
bodyParagraph_2.ApplyStyle("paraStyle")# Set the horizontal alignment of the paragraphs
titleParagraph.Format.HorizontalAlignment = HorizontalAlignment.Center
bodyParagraph_1.Format.HorizontalAlignment = HorizontalAlignment.Left
bodyParagraph_2.Format.HorizontalAlignment = HorizontalAlignment.Left# Set the after spacing
titleParagraph.Format.AfterSpacing = 10
bodyParagraph_1.Format.AfterSpacing = 10# Save to file
doc.SaveToFile("output/WordDocument.docx", FileFormat.Docx2019)

http://www.yayakq.cn/news/754832/

相关文章:

  • 嘉兴网站建设书生商友室内设计资源网
  • wordpress获取地址栏参数系统优化方法
  • 网站页面大小优化怎么做phpmysql网站开发视频
  • 军事网址大全2345深圳网站关键词优化排名
  • 专门做三国战纪的网站叫什么意思东港建站公司
  • 烟台网站建设联系电话北京朝阳区网站建设
  • 秦皇岛学网站建设如何查询网站的访问量
  • 建设个网站从哪里盈利电商网店运营实训报告
  • 太原网站优化常识nonce验证 wordpress
  • 制定网站建设方案做网站需要多少空间
  • 大兴模版网站开发公司哪家好企业网站群建设方案
  • 网站建设的所需解决的技术问题设计公司logo需要注意什么
  • 门户网站建设 交流发言专业维护网站的公司
  • 网站建设与设计实验报告企业网站开源代码下载
  • 青岛网站建设详细内容做网站有哪些主题
  • 建自己的网站用多少钱精品资料网提供企业管理知识
  • 深圳官方网站建设聚名网评价
  • 网站建设公司 北京门户网站制作的公司
  • 男和男人怎么做那个视频网站营销型网站建立费用
  • 做网站需要哪些技术支持win主机怎样实现wordpress固定链接静态化
  • 国外做装修设计网站做的电影网站很卡
  • 网站开发如何给用户发邮件网站教程设计
  • 做网站可以赚钱吗知乎做阿里网站
  • 建材有限公司光速东莞网站建设制作h5网页软件
  • 中文网站的英文广州建设执业资格注册中心网站
  • 漂亮的网站底部代码怎样让客户做网站
  • 泉州找工作哪个网站好网站建设的论文
  • 用自己电脑做主机做网站网站建设技术招聘
  • 网站后台管理系统源码阿里企业邮箱网页版
  • 郑州大型网站建设价格dedecms旅游网站模板