title: How to create timestamp variable in Python?
body: <p>I am trying to create a timestamp variable which actually stores the present time and outputs the time at that instance. A reproducible code is also included:</p>
  
  <pre><code>import time
  from datetime import datetime
  t = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  for i in range(5):
      time.sleep(2)
      print t
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <pre><code>2015-03-11 11:28:53
  2015-03-11 11:28:53
  2015-03-11 11:28:53
  2015-03-11 11:28:53
  2015-03-11 11:28:53
  </code></pre>
  
  <p><strong>Desired output</strong></p>
  
  <pre><code>2015-03-11 11:28:53
  2015-03-11 11:28:55
  2015-03-11 11:28:57
  2015-03-11 11:28:59
  2015-03-11 11:29:01
  </code></pre>
  
  <p>Any easy way to do this instead of placing the command </p>
  
  <pre><code>datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  </code></pre>
  
  <p>multiple times in the code.</p>