zoukankan      html  css  js  c++  java
  • 使用python删除文件(xlsx,xlsm,pptx,pptm,docx)个人信息

    库安装命令

    yum install python-pip
    pip install --upgrade pip
    pip install -U setuptools
    
    pip install python-pptx
    pip install python-docx
    pip install openpyxl
    
    sudo pip install --upgrade lxml

    delete_private_info_for_docx.py

    #!/usr/bin/python
    # -*- coding: UTF-8 -*-
    
    # #docx
    from docx import Document
    import sys
    
    fileName = sys.argv[1]
    
    prs = Document(fileName)
    
    #print(prs.core_properties.author)
    #print(prs.core_properties.last_modified_by)
    
    prs.core_properties.author = ""
    prs.core_properties.last_modified_by = ""
    
    prs.save(fileName)

    delete_private_info_for_pptm.py

    #!/bin/python
    # -*- coding: utf-8 -*-
    
    from pptx import Presentation
    import sys
    
    
    fileName = sys.argv[1]
    print(fileName)
    
    prs = Presentation(fileName)
    
    
    print(prs.core_properties.author)
    print(prs.core_properties.last_modified_by)
    
    prs.core_properties.author = ""
    prs.core_properties.last_modified_by = ""
    
    prs.save(fileName)

    delete_private_info_for_pptx.py

    #!/bin/python
    # -*- coding: utf-8 -*-
    
    from pptx import Presentation
    import sys
    
    
    fileName = sys.argv[1]
    print(fileName)
    
    prs = Presentation(fileName)
    
    
    print(prs.core_properties.author)
    print(prs.core_properties.last_modified_by)
    
    prs.core_properties.author = ""
    prs.core_properties.last_modified_by = ""
    
    prs.save(fileName)

    delete_private_info_for_xlsm.py

    #!/bin/python
    # -*- coding: utf-8 -*-
    
    from openpyxl import load_workbook
    import sys
    
    fileName = sys.argv[1]
    print(fileName)
    wb = load_workbook(fileName, keep_vba=True)
    
    wb.properties.creator=""
    wb.properties.last_modified_by=""
    
    wb.save(fileName)

    delete_private_info_for_xlsx.py

    #!/bin/python
    # -*- coding: utf-8 -*-
    
    from openpyxl import load_workbook
    import sys
    
    fileName = sys.argv[1]
    print(fileName)
    # wb = load_workbook(fileName, keep_vba=True)
    wb = load_workbook(fileName)
    
    wb.properties.creator=""
    wb.properties.last_modified_by=""
    
    
    wb.save(fileName)
  • 相关阅读:
    python assert断言函数
    Python中错误之 TypeError: object() takes no parameters、TypeError: this constructor takes no arguments
    python 3.5构建WINDOWS推送服务
    Python调用(运行)外部程序
    sqlalchemy相关知识
    利用rabbit_mq队列消息实现对一组主机进行命令下发
    Centos 下安装Zabbix Linux 客户端
    Lynis 2.2.0 :面向Linux系统的安全审查和扫描工具
    防暴力破解 Fail2Ban之python
    linux服务器被攻击处理过程
  • 原文地址:https://www.cnblogs.com/gaoBlog/p/14042483.html
Copyright © 2011-2022 走看看