Python office | 深入了解文件的属性
Kate 2020-11-12 22:24:50
Last updated
Kate 2020-11-12 22:24:50
Last updated
# contain pptx,docx,excel
from docx import Document
from pptx import Presentation
import openpyxl
def getDocProperties(docFile):
properties = Document(docFile).core_properties
return {'Author': properties.author,
'Created': properties.created,
'Last Modified': properties.last_modified_by,
'Modified': properties.modified}
def getPPTProperties(pptFile):
properties = Presentation(pptFile).core_properties
return {'Author': properties.author,
'Created': properties.created,
'Last Modified': properties.last_modified_by,
'Modified': properties.modified}
def getExcelProperties(excelFile):
properties = openpyxl.load_workbook(excelFile).properties
return {'Author': properties.author,
'Created': properties.created,
'Last Modified': properties.last_modified_by,
'Modified': properties.modified}