title: How to save python screen output to a text file
body: <p>I'd like to query items from a dict and save the printed output to a text file.</p>
  <p>Here's what I have:</p>
  <pre><code>import json
  import exec.fullog as e
  
  inp = e.getdata() #inp now is a dict() which has items, keys and values.
  
  #Query
  
  print('Data collected on:', inp['header']['timestamp'].date())
  print('\n CLASS 1 INFO\n')
  
  for item in inp['Demographics']:
      if item['name'] in ['Carly', 'Jane']:
          print(item['name'], 'Height:', item['ht'], 'Age:', item['years'])
  
  for item in inp['Activity']:
      if item['name'] in ['Cycle', 'Run', 'Swim']:
          print(item['name'], 'Athlete:', item['athl_name'], 'Age:', item['years'])
  </code></pre>