I tried using: %%capture my_cap
but it gives an error:
TypeError: run_cell() missing 1 required positional argument: 'raw_cell'
So it's unusable :-( Any other options out there?
In the first cell include this:
from IPython.utils.capture import CapturedIO
capture = CapturedIO(sys.stdout, sys.stderr)
...
...
# at the end of desired output:
cmem = capture.stdout
In the 2nd cell you can access variable cmem
:
print(cmem)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With