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)
  • 相关阅读:
    Coursera 算法二 week 5 BurrowsWheeler
    pta 编程题7 List Leaves
    pta 编程题6 树的同构
    pta编程题5 Pop Sequence
    pat乙级1067
    pat乙级1060
    pat乙级1059
    1.ActionBar
    安卓开发必须收藏的网站
    genymotion常见问题解答
  • 原文地址:https://www.cnblogs.com/gaoBlog/p/14042483.html
Copyright © 2011-2022 走看看