title: How to use Python to execute a cURL command?
body: <p>I want to execute a curl command in Python.</p>
  <p>Usually, I just need to enter the command in the terminal and press the return key. However, I don't know how it works in Python. </p>
  <p>The command shows below:</p>
  <pre><code>curl -d @request.json --header &quot;Content-Type: application/json&quot; https://www.googleapis.com/qpxExpress/v1/trips/search?key=mykeyhere
  </code></pre>
  <p>There is a <code>request.json</code> file to be sent to get a response.</p>
  <p>I searched a lot and got confused. I tried to write a piece of code, although I could not fully understand it and it didn't work.</p>
  <pre><code>import pycurl
  import StringIO
  
  response = StringIO.StringIO()
  c = pycurl.Curl()
  c.setopt(c.URL, 'https://www.googleapis.com/qpxExpress/v1/trips/search?key=mykeyhere')
  c.setopt(c.WRITEFUNCTION, response.write)
  c.setopt(c.HTTPHEADER, ['Content-Type: application/json','Accept-Charset: UTF-8'])
  c.setopt(c.POSTFIELDS, '@request.json')
  c.perform()
  c.close()
  print response.getvalue()
  response.close()
  </code></pre>
  <p>The error message is <code>Parse Error</code>. How to get a response from the server correctly?</p>