title: How can I Save a Python Script output to a file when using Command Prompt?
body: <p>I am using a speech-to-text example from Microsoft <a href="https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/samples/python/console" rel="nofollow noreferrer">example here</a>. </p>
  
  <p>After following the steps, we can run the example with this command (in command prompt)</p>
  
  <pre><code>python3 main.py 
  </code></pre>
  
  <p>And, in the command prompt all the results are showed. Great! </p>
  
  <p>However, I want to save all the results into a file (could be JSON, txt, csv...). I saw on Stackoverflow some other persons with the same issue <a href="https://stackoverflow.com/questions/30506069/how-to-save-python-coding-in-command-prompt-as-a-file">here</a> (however this is not really working in my example), and I knew from a previous project that I could save results to a JSON file (with Scrapy), with a command like this: </p>
  
  <pre><code>scrapy crawl Script -o name_json_file.json
  </code></pre>
  
  <p><strong>Therefore my question</strong>: Can I - directly save - all the results (that the Command Prompt shows) to a file when using the command prompt? And if not, what is the best (alternative) way to save the outputs in a file?</p>
  
  <p>Many thanks! </p>