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

小城市做网站合肥建站公司seo

小城市做网站,合肥建站公司seo,怎么修改网站上的内容,asp.net网站第一次运行慢文章目录 一、思路构建二、开始实现三、存在的问题3.1 解析doc文档遇到问题及解决方法#xff1a;3.2 解析ppt文档遇到问题及解决方法#xff1a; 四、读取pdf中的图片 一、思路构建 Zip文件和初始化文件放在同一个文件夹下#xff1b;然后解析zip文件读取到一个新的文件夹… 文章目录 一、思路构建二、开始实现三、存在的问题3.1 解析doc文档遇到问题及解决方法3.2 解析ppt文档遇到问题及解决方法 四、读取pdf中的图片 一、思路构建 Zip文件和初始化文件放在同一个文件夹下然后解析zip文件读取到一个新的文件夹下然后进入这个新的文件夹开始读取遇到新文件夹就进入读取所有的pdf、docs、doc、ppt并转为txt合并入新的txt 二、开始实现 安装环境 pip install python-pptx pip install pdfplumber pip install python-docx apt-get install antiword apt-get install libreoffice读取pptx 以文本在list里的形式返回如[“第一段”,“第二段”] def _parse_pptx(self):if not os.path.isfile(self.file_path):print(f[WARNING] cant find {self.file_path})txt_list []prs Presentation(self.file_path)for slide in prs.slides:for shape in slide.shapes:if not shape.has_text_frame:continuefor paragraph in shape.text_frame.paragraphs:for run in paragraph.runs:txt_list.append(run.text)return txt_list 读取docx 以文本在list里的形式返回如[“第一段”,“第二段”] def _parse_docx(self):if not os.path.isfile(self.file_path):print(f[WARNING] cant find {self.file_path})txt_list []doc Document(self.file_path)for paragraph in doc.paragraphs:txt_list.append(paragraph.text \n)return txt_list读取pdf 以文本在list里的形式返回如[“第一段”,“第二段”] def _parse_pdf(self):if not os.path.isfile(self.file_path):print(f[WARNING] cant find {self.file_path})txt_list []with pdfplumber.open(self.file_path) as pdf:for page in pdf.pages:txt_list.append(page.extract_text())return txt_list三、存在的问题 .doc .ppt 如何处理docx中一些删除线的也会识别进来文档应该避免删除线这种形式应直接删除解压zip时中文乱码 3.1 解析doc文档遇到问题及解决方法 pip install pypiwin32报错 INFO: pip is looking at multiple versions of pypiwin32 to determine which version is compatible with other requirements. This could take a while.Using cached pypiwin32-219.zip (4.8 MB)Preparing metadata (setup.py) ... errorerror: subprocess-exited-with-error× python setup.py egg_info did not run successfully.│ exit code: 1╰─ [7 lines of output]Traceback (most recent call last):File string, line 2, in moduleFile pip-setuptools-caller, line 34, in moduleFile /tmp/pip-install-5ufsbmju/pypiwin32_d42420d9531d46289d9e8ad3dd35073f/setup.py, line 121print Building pywin32, pywin32_version^SyntaxError: Missing parentheses in call to print. Did you mean print(Building pywin32, pywin32_version)?[end of output]note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed× Encountered error while generating package metadata. ╰─ See above for output.note: This is an issue with the package mentioned above, not pip. hint: See above for details.解决方法 以下方法可以解决但是python解析doc文档文字的中间会有莫名的换行符建议输入尽量用最新版的docx格式的文档。 在 Ubuntu 上读取 .doc 文件可以使用 antiword 工具它可以将 Microsoft Word 文档转换为文本。你可以通过安装 antiword 并在 Python 中使用 subprocess 模块来实现。 以下是一个示例代码 首先确保你已经安装了 antiword sudo apt-get install antiword使用以下 Python 代码来读取 .doc 文件并将其转换为文本 import subprocessdef doc_to_text(doc_file):process subprocess.Popen([antiword, doc_file], stdoutsubprocess.PIPE)output, _ process.communicate()return output.decode(utf-8)# 示例用法 doc_file example.doc # 替换成你的.doc文件名 text doc_to_text(doc_file)# 将文本保存到txt文件 with open(output.txt, w, encodingutf-8) as file:file.write(text)在上述代码中我们定义了一个名为 doc_to_text 的函数它接受一个 .doc 文件的路径作为参数。函数使用 subprocess.Popen 调用 antiword将其输出捕获并将其解码为 UTF-8 字符串。 示例用法中你需要将 ‘example.doc’ 替换为你的 .doc 文件名。运行这段代码后它会将 .doc 文件的内容转换为文本并保存到名为 output.txt 的文本文件中。 请注意antiword 可能无法处理包含复杂格式、表格等的 .doc 文件。如果你需要处理这些特殊情况可能需要考虑使用更复杂的工具或库。 3.2 解析ppt文档遇到问题及解决方法 直接解析ppt发现很难这里把ppt转为pdf然后再把pdf转txt 环境 sudo apt install libreoffice代码 staticmethod def convert_ppt_to_pdf(ppt_file, output_folder/home/gykj/thomascai/data/Archive1024/new_Archive.zip):output_file os.path.join(output_folder, os.path.splitext(os.path.basename(ppt_file))[0] .pdf)cmd fsoffice --headless --convert-to pdf --outdir {output_folder} {ppt_file}subprocess.run(cmd, shellTrue)print(fSuccessfully converted {ppt_file} to {output_file})return output_filedef _parse_ppt(self):output_file self.convert_ppt_to_pdf(self.file_path)self._set_file_path(output_file)self._parse_pdf()四、读取pdf中的图片 pip install PyMuPDF由于页与页之间的连接原因pdf转markdown先 (未完待续关注不迷路谢谢~)
http://www.dnsts.com.cn/news/3809.html

相关文章:

  • 做海报的网站什么编辑器可以做外链视频的网站
  • 教育网站开发背景wordpress软件
  • 学做网站教程深圳建网站培训机构
  • 专门做家具网站动画设计说明
  • 高唐企业网站建设wordpress支持多少会员
  • 一流的福州网站建设宁波seo的公司联系方式
  • 网站制作的动画怎么做的滕州外贸软件公司
  • 上海 网站备案系统灵璧做网站的公司
  • vue低代码开发平台网站优化报价
  • 得力企业网站建设网站开发嘉比格网络
  • 电子科技网站建设青岛如何建立企业网站企业
  • 做网站自己上传电影要多大服务器建设营销网站多少钱
  • 网站模板 收费如何找外贸公司合作
  • 百度网站建设费用多少知乎网站建设程序员做什么
  • 网站推广适合女生做吗做h5页面的网站蘑菇
  • 微信微网站是什么情况衡水做wap网站费用
  • 成都网站建站企业网站建设的方法
  • m开头的可以做网站的软件国外的建筑设计案例网站
  • 爱淘苗网站开发模式WordPress给文章添加省份
  • 合肥网站制作哪家强网站被k文章修改
  • wordpress多站点管理台山网站建设
  • asp.net网站访问统计7k网站怎么做
  • php 手机网站源码旅游网站建设普通论文
  • 建设网站的基本工作流程淘宝推广引流方法有哪些
  • 做企业网站可以没有后台吗有什么兼职做it的网站好
  • html5高端网站建设织梦模板阳江本地最新招聘信息
  • wordpress能做手机站么网站框架有哪些
  • 连云港做网站建设哈尔滨招标信息网官网
  • 湘潭网站建设 x磐石网络西安网页设计多少钱
  • 服务器怎么建网站公司广告宣传片拍摄