python讀取docx文件屬性-最后一次保存的時間等


可以用docx獲取,但是總有幾個文件會報錯,所以使用直接獲取的方式

import zipfile
import xml.dom.minidom as xdom

def find_zip_prop(p):
	azip = zipfile.ZipFile(p)
	a = azip.read('docProps/core.xml').decode('utf-8')
	xp = xdom.parseString(a)
	root=xp.documentElement
	ele=root.getElementsByTagName('dcterms:modified')
	print(ele[0].firstChild.data)
	ele=root.getElementsByTagName('dcterms:created')
	print(ele[0].firstChild.data)
	azip.close()

if __name__=='__main__':
	p=r'D:\aaa.docx'
	find_zip_prop(p)

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM