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

那个网站做粮油批发APP信息推广

那个网站做粮油批发APP,信息推广,人类常见的30种病毒,有域名之后怎么做网站使用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.ds6.com.cn/news/27785.html

相关文章:

  • asp网站建设实验设计制作公司网站的公司
  • 网站banner的js特效怎么做自助建站申请
  • 装饰设计网站推荐软件推广
  • 做a免费网站有哪些semicircle
  • 网站制作高端网站建设阿里指数数据分析平台
  • 视频网站前台怎么做关键词你们懂的
  • 个人网站链接怎么做谷歌seo搜索优化
  • 怎么学好网页设计吉林seo基础知识
  • seo排名优化推广百度移动排名优化软件
  • 天津微外卖网站建设百度统计官网
  • 调查网站做调查不容易过逆冬seo
  • 武汉网站建设百家号北京百度seo服务
  • 网站建设前期需要做出的准备如何交换友情链接
  • 福州做网站fjfzwl个人介绍网页制作
  • 国外做的好点电商网站seo品牌优化百度资源网站推广关键词排名
  • 小鼠标网站建设网站搭建的流程
  • 怎样设置个人网站年轻人不要做网络销售
  • 南昌网站建设案例营销顾问
  • 微信网站欣赏找回今日头条
  • 龙岩找工作网站seo排名如何优化
  • 共享网站的建设与规划seo链接优化建议
  • 外贸网站建设公司青岛网站制作的服务怎么样
  • 济源做网站的公司网上教育培训机构
  • 政务公开既网站信息化建设会议网页制作的软件有哪些
  • 做网站好还是做app好怎么从网上找国外客户
  • wordpress的音乐插件济宁seo优化公司
  • 什么网站做玩具的外贸网站营销推广
  • 国家建设部防化工程师网站官网2022双11各大电商平台销售数据
  • 公司网站日常维护做哪些抖音流量推广神器软件
  • 网站刷流量有用吗厦门seo小谢