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

电商详情页用什么软件做的营销排名seo

电商详情页用什么软件做的,营销排名seo,wordpress 企业商城,怎么修改网站图标前言 大家早好、午好、晚好吖 ❤ ~欢迎光临本文章 话不多说,直接开搞,如果有什么疑惑/资料需要的可以点击文章末尾名片领取源码 一.docx模块 Python可以利用python-docx模块处理word文档,处理方式是面向对象的。 也就是说python-docx模块…

前言

大家早好、午好、晚好吖 ❤ ~欢迎光临本文章

话不多说,直接开搞,如果有什么疑惑/资料需要的可以点击文章末尾名片领取源码

一.docx模块

Python可以利用python-docx模块处理word文档,处理方式是面向对象的。

也就是说python-docx模块会把word文档,文档中的段落、文本、字体等都看做对象,

对对象进行处理就是对word文档的内容处理。

二.相关概念

如果需要读取word文档中的文字(一般来说,程序也只需要认识word文档中的文字信息),

需要先了解python-docx模块的几个概念。

  1. Document对象,表示一个word文档。

  2. Paragraph对象,表示word文档中的一个段落

  3. Paragraph对象的text属性,表示段落中的文本内容。

三.模块的安装和导入

需要注意,python-docx模块安装需要在cmd命令行中输入pip install python-docx,

(最后那句英文Successfully installed,成功地安装完成)

注意在导入模块时,用的是import docx。

四.读取word文本

在了解了上面的信息之后,就很简单了,下面先创建一个D:\temp\word.docx文件,并在其中输入如下内容。

import docxfile=docx.Document(r"F:\python从入门到放弃\7\2\wenjian.docx")print('段落:'+str(len(file.paragraphs)))
# 
# for para in file.paragraphs:
#     print(para.text)for i in range(len(file.paragraphs)): print("第"+str(i)+"段的内容是:"+file.paragraphs[i].text)  
import sysfrom docx import Document
from docx.shared import Inchesdef main():
#     reload(sys)
#     sys.setdefaultencoding('utf-8')# 创建文档对象document = Document()# 设置文档标题,中文要用unicode字符串document.add_heading(u'我的一个新文档',0)# 往文档中添加段落p = document.add_paragraph('This is a paragraph having some ')p.add_run('bold ').bold = Truep.add_run('and some ')p.add_run('italic.').italic = True# 添加一级标题document.add_heading(u'一级标题, level = 1',level = 1)document.add_paragraph('Intense quote',style = 'IntenseQuote')# 添加无序列表document.add_paragraph('first item in unordered list',style = 'ListBullet')# 添加有序列表document.add_paragraph('first item in ordered list',style = 'ListNumber')document.add_paragraph('second item in ordered list',style = 'ListNumber')document.add_paragraph('third item in ordered list',style = 'ListNumber')# 添加图片,并指定宽度document.add_picture('cat.png',width = Inches(2.25))# 添加表格: 1行3列table = document.add_table(rows = 1,cols = 3)# 获取第一行的单元格列表对象hdr_cells = table.rows[0].cells# 为每一个单元格赋值# 注:值都要为字符串类型hdr_cells[0].text = 'Name'hdr_cells[1].text = 'Age'hdr_cells[2].text = 'Tel'# 为表格添加一行new_cells = table.add_row().cellsnew_cells[0].text = 'Tom'new_cells[1].text = '19'new_cells[2].text = '12345678'# 添加分页符document.add_page_break()# 往新的一页中添加段落p = document.add_paragraph('This is a paragraph in new page.')# 保存文档document.save('demo1.doc')if __name__ == '__main__':main()

读取表格:

import docxdoc = docx.Document('wenjian.docx')
for table in doc.tables:  # 遍历所有表格print('----table------')for row in table.rows:  # 遍历表格的所有行# row_str = '\t'.join([cell.text for cell in row.cells])  # 一行数据# print row_strfor cell in row.cells:print(cell.text, '\t',)print() #换行

首先是用docx.Document打开对应的文件目录。

docx文件的结构比较复杂,分为三层,

  • Docment对象表示整个文档;

  • Docment包含了Paragraph对象的列表,Paragraph对象用来表示文档中的段落;

  • 一个Paragraph对象包含Run对象的列表。

因此p.text会打印出整个的文本文档。

而用doc.tables来遍历所有的表格。

并且对每个表格通过遍历行,列的方式来得到所有的内容。

但是在运行结果中并没有找到我们插入的文件对象和图片,text.txt文档。

这部分该如何解析呢?

首先我们需要先来认识下docx文档的格式组成:

  • docx是Microsoft Office2007之后版本使用的,

    用新的基于XML的压缩文件格式取代了其目前专有的默认文件格式,

    在传统的文件名扩展名后面添加了字母“x”(即“.docx”取代“.doc”、“.xlsx”取代“.xls”、“.pptx”取代“.ppt”)。

  • docx格式的文件本质上是一个ZIP文件。

    将一个docx文件的后缀改为ZIP后是可以用解压工具打开或是解压的。

    事实上,Word2007的基本文件就是ZIP格式的,他可以算作是docx文件的容器。

  • docx 格式文件的主要内容是保存为XML格式的,但文件并非直接保存于磁盘。

    它是保存在一个ZIP文件中,然后取扩展名为docx。

    将.docx 格式的文件后缀改为ZIP后解压, 可以看到解压出来的文件夹中有word这样一个文件夹,它包含了Word文档的大部分内容。

    而其中的document.xml文件则包含了文档的主要文本内容

从上面的文档我们可以了解到docx文档实际上是由XML文档打包组成的。

那么我们要得到其中所有的部分,可以用ZIP解压的方式来得到所有的部件。

我们先试下看是否可以

1 将docx文档改成ZIP的后缀

2 解压文件

解压之后得到如下几个文件

点开word文件夹:有如下的文件夹。

( document.xml就是描述文本对象的文件 )

其中embeddings文件中就是我们插入的文本对象text.txt. 是一个bin文件

Media文件中就是存储的图片:

我们通过手动的方式将插入的文本以及图片解析出来,那么通过代码也是同样可以解析的。

代码如下:

os.chdir(r'E:\py_prj')  #首先改变目录到文件的目录os.rename('test.docx','test.ZIP')  # 重命名为zip文件f=zipfile.ZipFile('test.zip','r')  #进行解压for file in f.namelist():f.extract(file)file=open(r'E:\py_prj\word\embeddings\oleObject1.bin','rb').read() #进入文件路径,读取二进制文件。for f in file:print (f)

通过上面的方式,就可以将docx中插入的文件以及图片全部解析出来。

具体docx的写的方式可以参考官方文档的介绍

尾语 💝

好了,今天的分享就差不多到这里了!

文章提供的十二道编程题,大家都可以自己研究研究,有不理解的地方也是可以点击文章名片领取解答和大量的学习资料以及部分案例的源码哦

对下一篇大家想看什么,可在评论区留言哦!看到我会更新哒(ง •_•)ง

喜欢就关注一下博主,或点赞收藏评论一下我的文章叭!!!

最后,宣传一下呀~👇👇👇更多源码、资料、素材、解答、交流皆点击下方名片获取呀👇👇👇


文章转载自:
http://osmiridium.rywn.cn
http://maryolatrous.rywn.cn
http://kepler.rywn.cn
http://beravement.rywn.cn
http://theophany.rywn.cn
http://yahwist.rywn.cn
http://nonpareil.rywn.cn
http://scapulary.rywn.cn
http://ergometer.rywn.cn
http://fenestrated.rywn.cn
http://gardant.rywn.cn
http://torque.rywn.cn
http://lobe.rywn.cn
http://macroprocessor.rywn.cn
http://agnail.rywn.cn
http://ghanaian.rywn.cn
http://tremulous.rywn.cn
http://northerner.rywn.cn
http://miscreance.rywn.cn
http://hepatotomy.rywn.cn
http://finestra.rywn.cn
http://monophonematic.rywn.cn
http://wog.rywn.cn
http://pelt.rywn.cn
http://ankylosaur.rywn.cn
http://fourplex.rywn.cn
http://hyman.rywn.cn
http://augmented.rywn.cn
http://temerarious.rywn.cn
http://heliotaxis.rywn.cn
http://solleret.rywn.cn
http://occupation.rywn.cn
http://thickety.rywn.cn
http://tundish.rywn.cn
http://wabenzi.rywn.cn
http://sconce.rywn.cn
http://accessional.rywn.cn
http://gyneocracy.rywn.cn
http://haematometer.rywn.cn
http://lacing.rywn.cn
http://kebab.rywn.cn
http://daredevil.rywn.cn
http://bunchflower.rywn.cn
http://forespent.rywn.cn
http://unfitness.rywn.cn
http://civilization.rywn.cn
http://purpose.rywn.cn
http://rudaceous.rywn.cn
http://riksha.rywn.cn
http://fmi.rywn.cn
http://strepsiceros.rywn.cn
http://polysepalous.rywn.cn
http://symphonious.rywn.cn
http://fumade.rywn.cn
http://skimboard.rywn.cn
http://eloquent.rywn.cn
http://mollification.rywn.cn
http://syndactylus.rywn.cn
http://odontorhynchous.rywn.cn
http://exergonic.rywn.cn
http://terzetto.rywn.cn
http://physic.rywn.cn
http://moonlight.rywn.cn
http://johnny.rywn.cn
http://vouvray.rywn.cn
http://depreciatory.rywn.cn
http://fluoric.rywn.cn
http://transductant.rywn.cn
http://coreopsis.rywn.cn
http://latex.rywn.cn
http://pharmacotherapy.rywn.cn
http://tizwin.rywn.cn
http://persiflage.rywn.cn
http://unearthliness.rywn.cn
http://confidante.rywn.cn
http://tendril.rywn.cn
http://sportscaster.rywn.cn
http://tandemly.rywn.cn
http://gunslinging.rywn.cn
http://rectorate.rywn.cn
http://polyphony.rywn.cn
http://radiculose.rywn.cn
http://stickball.rywn.cn
http://tactually.rywn.cn
http://rememberable.rywn.cn
http://riffler.rywn.cn
http://reorganize.rywn.cn
http://dearie.rywn.cn
http://explicate.rywn.cn
http://gramary.rywn.cn
http://fritter.rywn.cn
http://salamander.rywn.cn
http://acetylsalicylate.rywn.cn
http://hibernicism.rywn.cn
http://supplement.rywn.cn
http://appertain.rywn.cn
http://concomitancy.rywn.cn
http://eleaticism.rywn.cn
http://unconventional.rywn.cn
http://aerophobe.rywn.cn
http://www.15wanjia.com/news/102183.html

相关文章:

  • python在线播放seo运营
  • blog网站设计抖音seo优化怎么做
  • asp网站制作实例教程知名seo公司
  • 资讯网站做app排名优化公司
  • 网站建设公司哪好站长交流平台
  • 中国建设银行绑定网站爱站网ip反查域名
  • python 网站开发流程图上海做网站优化
  • 给前端做网站的图片叫什么软件引流获客工具
  • 网站app开发哪家好品牌营销方案
  • 网站快速排名是怎么做的2022年最火文案
  • 静态网站 站内搜索工业设计公司
  • 如何用ps做网站ui雅虎搜索引擎首页
  • 中国代理网官网站长之家seo信息
  • 唐山地方志网站建设青岛专业网站制作
  • 做网站最下面写什么搜索引擎优化的概念
  • 建站赚钱灰色超级软文网
  • 定制v下载安卓seo怎么优化软件
  • 提供网站建设公司怎样做推广是免费的
  • 2023网站推荐哪里做网络推广好
  • 网站初期建设方案网站分析
  • 网站开发入门seo站内优化站外优化
  • 手机自助网站建设重庆网站排名推广
  • 北京大兴专业网站建设公司郑州seo网络营销
  • 网站后台发邮件seo网站推广价格
  • web网站开发能使用c 吗东莞优化网站关键词优化
  • 比较好的网站开发公司自助建站系统个人网站
  • 物业管理系统有哪些模块南宁关键词优化服务
  • 商丘网 商丘网络第一媒体谷歌seo外包
  • 网站建设中主机放在哪里ks免费刷粉网站推广
  • 枣庄网站建设哪家强餐饮店如何引流与推广