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

网站 案例台州建设信息港网站

网站 案例,台州建设信息港网站,做搜狗网站优化点击,网站建设哪些职位1、首先将后缀名(.docx)修改为压缩包格式(.zip)。 2、修改解密word加密.py里zip的位置,和新生成的zip的位置和名称 import zipfile import xml.etree.ElementTree as ET import os import shutil# 定义文件路径 zip_file_path rC:\Users\Administrator\Desktop\新…

1、首先将后缀名(.docx)修改为压缩包格式(.zip)。

2、修改解密word加密.py里zip的位置,和新生成的zip的位置和名称

import zipfile
import xml.etree.ElementTree as ET
import os
import shutil# 定义文件路径
zip_file_path = r'C:\Users\Administrator\Desktop\新建文件夹 (3)\小说 en.zip'
new_zip_file_path = r'C:\Users\Administrator\Desktop\新建文件夹 (3)\小说 en_modified.zip'
xml_file_path_in_zip = 'word/settings.xml'# 创建临时目录
temp_dir = 'temp_zip'
os.makedirs(temp_dir, exist_ok=True)# 打开 ZIP 文件
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:# 解压缩所有文件到临时目录zip_ref.extractall(temp_dir)# 构建完整的 XML 文件路径
xml_file_full_path = os.path.join(temp_dir, xml_file_path_in_zip)# 解析 XML 文件,并指定命名空间
tree = ET.parse(xml_file_full_path)
root = tree.getroot()# 定义命名空间
namespace = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}# 查找并修改 w:documentProtection 元素的 w:enforcement 属性
document_protection = root.find('.//w:documentProtection', namespace)
if document_protection is not None:if '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}enforcement' in document_protection.attrib:document_protection.attrib['{http://schemas.openxmlformats.org/wordprocessingml/2006/main}enforcement'] = 'false'# 将修改后的 XML 文件保存回临时目录
tree.write(xml_file_full_path, encoding='utf-8', xml_declaration=True, default_namespace='http://schemas.openxmlformats.org/wordprocessingml/2006/main')# 创建新的 ZIP 文件
with zipfile.ZipFile(new_zip_file_path, 'w', zipfile.ZIP_DEFLATED) as new_zip_ref:for foldername, subfolders, filenames in os.walk(temp_dir):for filename in filenames:file_path = os.path.join(foldername, filename)arcname = os.path.relpath(file_path, temp_dir)new_zip_ref.write(file_path, arcname)# 清理临时目录
shutil.rmtree(temp_dir)print(f'修改后的 ZIP 文件已保存到: {new_zip_file_path}')

3、运行解密word加密.py

4、将新生成的zip后缀改回.docx

5、打开.docx看是否已经解除密码保护了

http://www.yayakq.cn/news/64530/

相关文章:

  • 最专业微网站多少钱哪些网站做外贸
  • 网站更换服务器需要重新备案吗个人网站源码下载
  • 织梦设置中英文网站猎头网招聘
  • 爱民网站制作创新的常州做网站
  • 青岛城乡建设局网站首页南宁百度关键词推广
  • 做网站平台公司织梦模板怎么验证网站
  • 南昌seo网站推广费用杭州网站建设案例
  • 哈尔滨专门做网站网站建设初步规划书
  • 长沙建站价格网站建设要备案吗
  • 沧州网站建设一网美联公司网站服务器租用
  • 深圳找人做网站浙江省建设政务网站
  • 自学html做网站要多久重庆知名企业
  • 网站建设与规划心得南宁画册设计公司
  • 无锡网站建设优化兰州注册公司
  • 罗定市建设局网站在线外链
  • seo按照搜索引擎的什么对网站自动引流推广app
  • 自己建网站备案商务网站建设的一般流程是什么意思
  • 做网站难还是app难网站开发前端框架
  • c2c电子商务网站建设网站的费用
  • 沈阳建设企业网站四川网站建设的公司哪家好
  • 手机如何建设网站网站建设平台信息
  • 网站建设解决方案好处前端官网模板
  • 网站开发平台建设网站psd
  • 网站建设与维护案列龙岗大运做网站的公司
  • 宁波网站推广哪家公司好莆田的外贸网站
  • 石家庄做网站网络公司专业做包包的网站
  • 庆阳网站设计报价wordpress 美术
  • 太原便宜做网站的公司海口seo快速排名优化
  • 广东省建设厅的注册中心网站牙膏的网站建设
  • 怎么用ps做网站首页图片尺寸四川住房城乡建设厅官方网站