結果 : how to write terminal output to a file in python