f.write(xmlstr)
filenames = self.zipfile.namelist()
zip_copy_filename = output_filename
with zipfile.ZipFile(zip_copy_filename, 'w') as docx:
    for filename in filenames:
        docx.write(os.path.join(tmp_dir, filename), filename)
su.rmtree(tmp_dir)

def get_xml_tree(f):
    return xml.etree.ElementTree.parse(f)
word_doc = 'TEXT.docx'
new_word_doc = 'SLIM.docx'
doc = get_word_xml(word_doc)
tree = get_xml_tree(doc)
write_and_close_docx(word_doc, tree, new_word_doc)
Python - Remove header and footer from docx file