当前位置: 首页 > 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.mmbaike.com/news/98998.html

相关文章:

  • php网站开发注意问题如何创建网站
  • 嘉兴网站建设企业网站制作关键词优化快速
  • 域名做违法网站公众号推广费用一般多少
  • 临沂网站优化公司2022年新闻摘抄十条简短
  • 网站建设阶段要做什么一键生成网站
  • php程序员做企业网站5118关键词工具
  • 哪个行业最喜欢做网站能够免费换友链的平台
  • 济南制作网站公司哪家好交换链接适合哪些网站
  • 四川门户网站建设管理规定各大网站收录提交入口
  • php mysql网站开发书搜索大全引擎地址
  • 网站建设费用先付一半百度视频免费高清影视
  • 上海工程公司排名seo运营是什么
  • 什么网站可以兼职做平面设计软文技巧
  • 牌具网站广告怎么做西安专业网络推广平台
  • 投票网站做seo如何公司网站排名
  • 海口网络公司自己的网站怎么样推广优化
  • 客服外包公司排行榜seo网站权重
  • 站长推荐黄色大数据精准营销系统
  • 视频分享网站建设信阳网站推广公司
  • 茄子河区网站建设自查报告推广自己的网站
  • 刚成立的公司怎样做自己网站网址如何下载视频
  • 延安网站建设网络公司国内免费域名
  • 东阳营销型网站建设品牌短视频培训课程
  • 有做盆景的网站网站品牌推广公司
  • 网站做游客留言做网站seo具体怎么做
  • 潮州网站seo推广建网站找哪个平台好呢
  • 重庆网站建设服务价格武汉网络推广外包公司
  • 网站做3年3年包括什么软件吗5g网络优化培训
  • 做网站banner分辨率设置多大自己建站的网站
  • 网站开发报价单明细国内营销推广渠道