title: Print datetime in ISO format without milliseconds
body: <p>I'm trying to serialize datetime in an API, but I don't want milliseconds. What I want is here: <a href="https://en.wikipedia.org/wiki/ISO_8601" rel="noreferrer">https://en.wikipedia.org/wiki/ISO_8601</a> - <code>"2015-09-14T17:51:31+00:00"</code></p>
  
  <pre><code>tz = pytz.timezone('Asia/Taipei')
  dt = datetime.datetime.now()
  loc_dt = tz.localize(dt)
  </code></pre>
  
  <p>Try A:</p>
  
  <pre><code>loc_dt.isoformat()
  &gt;&gt; '2015-09-17T10:46:15.767000+08:00'
  </code></pre>
  
  <p>Try B:</p>
  
  <pre><code>loc_dt.strftime("%Y-%m-%dT%H:%M:%S%z")
  &gt;&gt; '2015-09-17T10:46:15+0800'
  </code></pre>
  
  <p>The latter one is almost perfect except it's missing the colon in the timezone part. How can I solve this without string manipulation (deleting milliseconds or adding colon)?</p>