[Python] Create an (XML) file in working memory, rather than writing locally (Python)...

Discussão em 'Python' iniciado por Stack, Janeiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    tl;dr - In python, is there a way to write a file in memory and store it in a variable, rather than writing it locally to disk?

    Use Case

    I'm trying to generate an XML file using the xml.etree.ElementTree package. I've been able to create a local file with ElementTree.write(etc.), which is helpful for checkout output/debugging. However, the next step is for me to create the full XML file in memory so that I can zip it (also in memory) and send it as part of an API POST without polluting the script's directory with single use files.

    Continue reading...

Compartilhe esta Página