當前位置:編程學習大全網 - 編程軟體 - 解壓縮程序設計

解壓縮程序設計

# -*-編碼:utf-8 -*-

#!/usr/bin/env python

導入docx

導入zip文件

從斯特林堡進口斯特林堡

從processing _ units . XML _ processing _ unit導入XmlProcessingUnit

導入文檔_工具

if __name__ == '__main__ ':

m = docx.opendocx('e:/test.docx ')

p = XmlProcessingUnit('docx ')

過程= p .過程(m)

zfile = zipfile。ZipFile('e:/test.docx ')

out_docx_file = StringIO()

doc_utils.save_docx(zfile,process,out_docx_file)

out_txt_file = StringIO()

doc_utils.docx_to_txt(輸出文件,輸出文件)

'''

out_file = StringIO()

用zipfile。ZipFile(out_file,' w ',compression=zipfile。ZIP_DEFLATED)為f:

f.writestr('test123.docx ',out_docx_file.getvalue())

#f.writestr('%s.txt' % out_file,out_txt_file.getvalue())

'''

zfile2 = zipfile。ZipFile('e:/test.zip ',' w ',ZipFile。ZIP _放氣)

zfile2.writestr('test.docx ',out_docx_file.getvalue())

#zfile2.writestr('test.txt ',out_txt_file.getvalue())

#result = out_file.getvalue()

#打印結果

out_docx_file.close()

out_txt_file.close()

#out_file.close()

中間少了壹個功能。自己找吧。

  • 上一篇:VC+++ 全局變量的定義
  • 下一篇:三星電視HDMI被鎖了
  • copyright 2024編程學習大全網