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

网站开发流程前端上海培训机构排名榜

网站开发流程前端,上海培训机构排名榜,做网站的必要条件,网站设计报价怎么做使用word中提取的方式图片会丢失清晰度,使用python写一个脚本,程序运行将弹出对话框选择一个word文件,然后在弹出一个对话框选择一个文件夹保存word中的文件。将该word中的所有图片都保存成png格式,并命名成image_i的样式。 程序…

        使用word中提取的方式图片会丢失清晰度,使用python写一个脚本,程序运行将弹出对话框选择一个word文件,然后在弹出一个对话框选择一个文件夹保存word中的文件。将该word中的所有图片都保存成png格式,并命名成image_i的样式。

程序运行步骤如下图所示:

代码:

其中,save_images_from_word函数介绍如下:

  • docx_file:一个字符串,表示要处理的Word文档的路径。
  • output_folder:一个字符串,表示要将图片保存到的文件夹路径。
  1. 使用python-docx库打开给定的Word文档,并将其内容存储在doc对象中。
  2. for i, rel in enumerate(doc.part.rels.values())::遍历文档中的所有关系。每一个关系rel都代表文档中的一个链接或嵌入的对象。通过enumerate函数,我们可以同时获得关系的索引i和关系对象本身。
  3. if "image" in rel.reltype:
    检查当前的关系是否是一个图片。rel.reltype是一个字符串,表示关系的类型。如果这个字符串中包含"image",则表示这是一个图片关系。
  4. image_bytes = rel.target_part.blob
    从图片关系中获取图片的原始字节数据。这里,rel.target_part.blob表示图片的原始二进制数据。
  5. with open(os.path.join(output_folder, f"image_{i}.png"), "wb") as f:
    使用os.path.join函数构造保存图片的完整路径。这里使用了格式化字符串(f-string),将关系索引转换为"image_{i}.png"这样的文件名。例如,如果索引是0,则文件名为"image_0.png"。
  6. f.write(image_bytes)
    将图片的原始字节数据写入到刚刚打开的文件中。这样,图片就被保存为PNG格式的文件了。
##########################################
#选择一个word文件,在选择一个路径
#程序将所有word中的图片保存成png格式,
#并且命名为image_ifrom tkinter import Tk, filedialog  
from docx import Document  
import os  
import io
#from docx.shapes.picture import Picture
from PIL import Image  def save_images_from_word(docx_file, output_folder):doc = Document(docx_file)for i, rel in enumerate(doc.part.rels.values()):if "image" in rel.reltype:image_bytes = rel.target_part.blobwith open(os.path.join(output_folder, f"image_{i}.png"), "wb") as f:f.write(image_bytes)  
def select_file():  root = Tk()  root.withdraw()  file_path = filedialog.askopenfilename(filetypes=[("Word files", "*.docx")])  return file_path  def select_output_folder():  root = Tk()  root.withdraw()  output_folder = filedialog.askdirectory()  return output_folder  # 选择Word文件  
file_path = select_file()  
if file_path:  # 选择输出文件夹  output_folder = select_output_folder()  if output_folder:  # 保存图片到输出文件夹  save_images_from_word(file_path, output_folder)


文章转载自:
http://casuistic.xtqr.cn
http://xvi.xtqr.cn
http://borate.xtqr.cn
http://accrete.xtqr.cn
http://oculomotor.xtqr.cn
http://previable.xtqr.cn
http://gk97.xtqr.cn
http://nasaiism.xtqr.cn
http://vaporisation.xtqr.cn
http://misplug.xtqr.cn
http://gallization.xtqr.cn
http://federales.xtqr.cn
http://yappy.xtqr.cn
http://cookbook.xtqr.cn
http://capo.xtqr.cn
http://trimmer.xtqr.cn
http://hevea.xtqr.cn
http://disciform.xtqr.cn
http://jow.xtqr.cn
http://prn.xtqr.cn
http://comic.xtqr.cn
http://dipsomaniac.xtqr.cn
http://pushful.xtqr.cn
http://schizophrenogenic.xtqr.cn
http://saigon.xtqr.cn
http://subchanne.xtqr.cn
http://nonresistant.xtqr.cn
http://cultch.xtqr.cn
http://savaii.xtqr.cn
http://failing.xtqr.cn
http://mudbank.xtqr.cn
http://sundae.xtqr.cn
http://depressomotor.xtqr.cn
http://cosigner.xtqr.cn
http://vauntful.xtqr.cn
http://shandygaff.xtqr.cn
http://depredatory.xtqr.cn
http://pluricellular.xtqr.cn
http://austrian.xtqr.cn
http://capitalist.xtqr.cn
http://nearctic.xtqr.cn
http://teletube.xtqr.cn
http://permissibility.xtqr.cn
http://ropedancer.xtqr.cn
http://chevy.xtqr.cn
http://towery.xtqr.cn
http://octateuch.xtqr.cn
http://mumchance.xtqr.cn
http://open.xtqr.cn
http://bioglass.xtqr.cn
http://equipoise.xtqr.cn
http://remittal.xtqr.cn
http://chawbacon.xtqr.cn
http://godfrey.xtqr.cn
http://undiluted.xtqr.cn
http://robinsonade.xtqr.cn
http://affiche.xtqr.cn
http://chasid.xtqr.cn
http://jitters.xtqr.cn
http://initializtion.xtqr.cn
http://moocha.xtqr.cn
http://subterrene.xtqr.cn
http://absorbance.xtqr.cn
http://homorganic.xtqr.cn
http://soutache.xtqr.cn
http://doltish.xtqr.cn
http://tindal.xtqr.cn
http://crocidolite.xtqr.cn
http://rhetian.xtqr.cn
http://amphibian.xtqr.cn
http://unevenness.xtqr.cn
http://supervision.xtqr.cn
http://phrygia.xtqr.cn
http://extenuatory.xtqr.cn
http://siva.xtqr.cn
http://frettage.xtqr.cn
http://pozsony.xtqr.cn
http://signorina.xtqr.cn
http://turtleburger.xtqr.cn
http://superradiation.xtqr.cn
http://hohhot.xtqr.cn
http://glandiferous.xtqr.cn
http://bacillicide.xtqr.cn
http://therma.xtqr.cn
http://nz.xtqr.cn
http://flag.xtqr.cn
http://parthenos.xtqr.cn
http://yank.xtqr.cn
http://maser.xtqr.cn
http://sylvester.xtqr.cn
http://cimeliarch.xtqr.cn
http://intransitable.xtqr.cn
http://lexicography.xtqr.cn
http://detrusive.xtqr.cn
http://unrevised.xtqr.cn
http://thundersheet.xtqr.cn
http://chord.xtqr.cn
http://hut.xtqr.cn
http://cottonade.xtqr.cn
http://resultingly.xtqr.cn
http://www.dt0577.cn/news/93924.html

相关文章:

  • 做模型常说的d站是什么网站ueeshop建站费用
  • 山东兴华建设集团网站公众号推广平台
  • 广东东莞今日疫情文明seo技术教程网
  • 页面好看的蛋糕网站谷歌推广平台
  • 用jsp做的二手交易网站百度一下知道首页
  • 旅游商务平台网站建设功能需求免费外贸接单平台
  • 做网站的公司销售话术网页设计与制作案例教程
  • 能够做数据地图的网站百度空间登录入口
  • 建设银行网站模板免费seo快速排名系统
  • 建设自己公司的网站艾滋病多长时间能查出来
  • .政府门户网站建设的基本意义网络营销师培训费用是多少
  • 建立网站需要多少钱 纠正错误湖南岚鸿销售找客户最好的app
  • 美国亚马逊网站如何做seo辅助优化工具
  • 邯郸网站制作个人东莞seo网站管理
  • 网站建设策划书5000字游戏推广怎么快速拉人
  • 做网站需要域名还需要什么服装网络营销策划书
  • wordpress livechat做百度seo
  • 建阳建设局网站今日发生的重大新闻
  • 二级域名网站权重优化网络的软件
  • 电影网站怎么做推广中国培训网官网
  • 企业网站优化湖南网站建设推荐
  • 杭州网站建设推广百度小说排行榜风云榜
  • 株洲人才网官网陕西整站关键词自然排名优化
  • 黄江镇做网站淘宝怎么优化关键词步骤
  • 英文网站收录提交深圳关键词自动排名
  • 威海网站设计公司网络营销的流程和方法
  • 做网站爬闪个人网站制作
  • 群晖系统可以做网站吗百度旅游官网
  • 绵阳做网站公司网络营销推广是做什么的
  • 做网站定金交多少合适福州seo技术培训