python自动移除excel文件密码(小工具)

安装 msoffcrypto-tool

使用pip命令安装: 打开命令行工具(如终端、命令提示符或Powershell),然后输入以下命令来安装msoffcrypto-tool:
pip install msoffcrypto-tool库,进行自动移除excel文件密码

python 复制代码
import msoffcrypto

# 已加密Excel文件路径
encrypted_file = "F:\解密前.xlsx"
# 未加密文件将保存的路径
unencrypted_file = "F:\解密后.xlsx"
# Excel文件密码
excel_password = "密码"

# 打开加密文件
with open(encrypted_file, "rb") as encrypted_file_fd:
    office_file = msoffcrypto.OfficeFile(encrypted_file_fd)

    # 使用密码解密
    office_file.load_key(password=excel_password)

    # 将解密内容写入新文件
    with open(unencrypted_file, "wb") as unencrypted_file_fd:
        office_file.decrypt(unencrypted_file_fd)

print(f"文件已解密并保存至:{unencrypted_file}")
相关推荐
金銀銅鐵6 小时前
[Python] 从《千字文》中随机挑选汉字
后端·python
cup1111 小时前
[技术复盘] Windows Python 打包实战:Nuitka 环境踩坑总结与 CI 自动化构建全指南
python·ai·环境变量·ci·nuitka·skill
aqi0013 小时前
15天学会AI应用开发(七)有了大模型为什么还要引入RAG
人工智能·python·大模型·ai编程·ai应用
金銀銅鐵14 小时前
用 Python 实现 Take-Away 游戏
python·游戏
copyer_xyf15 小时前
Agent 流程编排
后端·python·agent
copyer_xyf16 小时前
Agent RAG
后端·python·agent
copyer_xyf16 小时前
【RAG】向量数据库:milvus
后端·python·agent
copyer_xyf16 小时前
Agent 记忆管理
后端·python·agent
星云穿梭1 天前
用Python写一个带图形界面的学生管理系统——完整教程
python