title: python requests: how to check for "200 OK"
body: <p>What is the easiest way to check whether the response received from a requests post was &quot;200 OK&quot; or an error has occurred?</p>
  <p>I tried doing something like this:</p>
  <pre><code>....
  resp = requests.post(my_endpoint_var, headers=header_var, data=post_data_var)
  print(resp)
  if resp == &quot;&lt;Response [200]&gt;&quot;:
      print ('OK!')
  else:
      print ('Boo!')
  </code></pre>
  <p>The output on the screen is:</p>
  <pre><code>Response [200] (including the &quot;&lt;&quot; and &quot;&gt;&quot;)
  Boo!
  </code></pre>
  <p>So even though I am getting a 200, my check in the if statement is somehow not matching?</p>