Escreva saída de célula para arquivo Jupyter colab

%%capture cap --no-stderr
print_something()

with open('/path/to/capture.txt') as f:
    f.write(cap.stdout)
Lazy Lizard