How to change the writing mode of the ElementTree.write in Python

Viewed 21

Im trying to write the xml file by ElementTree.write, and this function's writing mode is append, but i want to overwrite the file what should i do to realize this goal?

    def write_xml(self, out_path: str):
        xml = ET.ElementTree(self.__root)
        xml.write(out_path)
0 Answers
Related