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

广州南沙发布小红书seo优化

广州南沙发布,小红书seo优化,网站建设seo,win10记事本怎么做网站使用python读取文件,其中pdf、docx、pptx可以直接读,.ppt和.doc文件不能直接读,需要转换成.pptx和.docx文件,并且需要区分系统 如果是linux系统,请先安装组件 #doc2docx yum install -y libreoffice-headless yum ins…

使用python读取文件,其中pdf、docx、pptx可以直接读,.ppt和.doc文件不能直接读,需要转换成.pptx和.docx文件,并且需要区分系统
如果是linux系统,请先安装组件

#doc2docx
yum install -y libreoffice-headless
yum install -y libreoffice-writer# ppt2pptx
yum install epel-release -y
yum install libgdiplus -y
pip3 install aspose.slides

python代码如下:

import osdef read_pptx(fp):import pptxprs = pptx.Presentation(fp)for i, slide in enumerate(prs.slides):# if i == 1:  在这里可以指定提取ppt的具体页数for shape in slide.shapes:if shape.has_text_frame:text_frame = shape.text_frameprint(str(i) + '页:' + text_frame.text)def read_ppt(fp):import platformos_type = platform.system()if os_type == "Windows":import win32com.client as wcpowerpoint = wc.Dispatch("PowerPoint.Application")wc.gencache.EnsureDispatch("PowerPoint.Application")powerpoint.Visible = 1ppt = powerpoint.Presentations.Open(fp)ppt.SaveAs(fp+"x")powerpoint.Quit()elif os_type == "Linux":import aspose.slides as slideswith slides.Presentation(fp) as presentation:presentation.save(fp+"x", slides.export.SaveFormat.PPTX)read_pptx(fp+"x")def read_docx(fp):import docxfile = docx.Document(fp)print("段落数:" + str(len(file.paragraphs)))  # 段落数为13,每个回车隔离一段# 输出每一段的内容for para in file.paragraphs:print(para.text)def read_doc(fp):import platformos_type = platform.system()if os_type == "Windows":import doc2docxdoc2docx.convert(fp,fp+"x")elif os_type == "Linux":import subprocesssubprocess.check_output(["soffice", "--headless", "–-invisible", "--convert-to", "docx", fp, "--outdir", fp+"x"])read_docx(fp + "x")def read_pdf(fp):import pdfplumberpdfFile = open(fp,"rb")pdf = pdfplumber.open(pdfFile)for page in pdf.pages:text = page.extract_text()print(text)# file_path = "*.pptx"
file_path = "*.ppt"
# file_path = "*.docx"
# file_path = "*.doc"
# file_path = "*.pdf"
file_extension = os.path.splitext(file_path)[-1].lower()
print("文件后缀:" + file_extension)
if file_extension == '.pptx':print("读取pptx文件")read_pptx(file_path)
elif file_extension == '.ppt':print("读取ppt文件")read_ppt(file_path)
elif file_extension == ".docx":print("读取docx文件")read_docx(file_path)
elif file_extension == ".doc":print("读取doc文件")read_doc(file_path)
elif file_extension == ".pdf":print("读取pdf文件")read_pdf(file_path)
http://www.zhongyajixie.com/news/19682.html

相关文章:

  • 免费自助建站软件有哪些百度手机助手app官方下载
  • 如何做网站商城seo收费
  • 免费网站开发框架seo推广公司哪家好
  • 做网站用到什么技术广州网站快速优化排名
  • 大型医疗网站建设seo黑帽技术有哪些
  • 网站建设信息模板站长工具综合查询系统
  • 品牌建设网站规划网推拉新app推广接单平台
  • 艺术网站制作排名优化哪家专业
  • 培训网站建设学校北京外贸网站优化
  • 企业网站开发有哪些今日军事新闻热点事件
  • 网站网页制作电话北京排名seo
  • 单页营销网站模板最权威的品牌排行榜网站
  • 做任务赚钱的网站起什么名字好产品免费推广网站有哪些
  • 燕郊个人做网站关键词排名手机优化软件
  • 用ai怎么做网站山西seo优化
  • wordpress做的学校网站会计培训班一般收费多少
  • 微信公众号和wordpress合肥seo排名收费
  • 中国十大网站建设企业网站运营策划书范文
  • 特产网站模板中国十大电商公司排名
  • 网站建设服务费武汉seo优化排名公司
  • 安庆网站建设服务网青岛百度推广优化
  • c 网站开发实例seo关键词优化工具
  • 永清建设局网站网络营销案例ppt
  • 武汉装修公司哪家好什么是网站seo
  • 深圳西乡网站建设公司seo推广方案怎么做
  • 店铺设计效果图河源网站seo
  • 国外可以做自媒体的网站营销案例
  • 球类网站如何做宣传哈尔滨怎样关键词优化
  • 手机网站开发应注意推广渠道有哪些
  • 做网站需要服务器和什么软件外包公司怎么赚钱