當前位置:編程學習大全網 - 編程軟體 - p編程文件

p編程文件

# -*-編碼: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()

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

  • 上一篇:c語言 LED燈閃爍程序實現P1、P2口閃爍三次熄滅,到P3、P4口閃爍三次在熄滅 回到開始在循環, 謝謝各位!急
  • 下一篇:電動車控制器120度的怎麽改成60度的
  • copyright 2024編程學習大全網