[Solved] How to save data in multiple files on python


Assuming you don’t care what the file names are, you could write each batch of messages to a new temp file, thus:

import tempfile

texts = some_function_grabbing_text()

while texts:
    with tempfile.TemporaryFile() as fp:
        fp.write(texts)
    texts = some_function_grabbing_text()

solved How to save data in multiple files on python