title: Append text to text file with timestamp
body: <p>I want to append the output from a python code into a text file. Above is my python code and i loop it for every 2 hour</p>
  
  <pre><code>if response == 0:
  print(hostname, "is up")
  
  if option == 1:
     print(option, "is the option')
     print('this is option number 1')
  elif option == 2:
     print(option, "is the option')
     print('this is option number 2')
  else:
     print(option, "is the other option')
     print('this is the result of other option')
  </code></pre>
  
  <p>i notice that i need the following code to append the result to a text file. </p>
  
  <pre><code>with open("test.txt", "a") as myfile:
  myfile.write("appended text")
  </code></pre>
  
  <p>How can i record every output to a text file and include time stamp to it? for example</p>
  
  <pre><code>09:10  192.168.0.1 is up
  09:10  1 is the option
  09:11  this is option number 1
  11:15  192.168.0.1 is up
  11:10  1 is the option
  11:11  this is option number 1
  13:10  192.168.0.1 is up
  13:10  3 is the other option
  13:11  this is the result of other option
  </code></pre>