Use the IPython magic function store
%store foo >a.txt # Store (overwrite) value of foo to file a.txt
%store foo >>a.txt # Append value of foo to file a.txt
Use the IPython magic function store
%store foo >a.txt # Store (overwrite) value of foo to file a.txt
%store foo >>a.txt # Append value of foo to file a.txt