title: In python how to convert string to datetime with timezone
body: <p>I am getting value error while converting string to datetime. Can anyone please help to resolve this issue.</p>
  
  <pre><code>&gt;&gt;&gt; from datetime import datetime
  &gt;&gt;&gt; date_str = "2018-07-13T17:12:02-0500"
  &gt;&gt;&gt; t = datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%S%z")
  
  Traceback (most recent call last):
  File "&lt;pyshell#27&gt;", line 1, in &lt;module&gt;
  t = datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%S%z")
  File "C:\Python27\lib\_strptime.py", line 324, in _strptime
  (bad_directive, format))
  ValueError: 'z' is a bad directive in format '%Y-%m-%dT%H:%M:%S%z'
  
  &gt;&gt;&gt; t = datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%S%Z")
  
  Traceback (most recent call last):
  File "&lt;pyshell#28&gt;", line 1, in &lt;module&gt;
  t = datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%S%Z")
  File "C:\Python27\lib\_strptime.py", line 332, in _strptime
  (data_string, format))
  ValueError: time data '2018-07-13T17:12:02-0500' does not match format '%Y- 
  %m-%dT%H:%M:%S%Z'
  &gt;&gt;&gt;
  </code></pre>
  
  <p>I am using python version 2.7.14</p>