title: How do I get the id from an ObjectID, using Python?
body: <p>I am trying to get the id from the document which I have in MongoDB, using PyMongo.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>docQuery = db.doctors.find({"email":doc_mail})
  doc_id = docQuery[0]["_id"]["$oid"]
  </code></pre>
  
  <p>I have tried this too:</p>
  
  <pre><code> doc_id = docQuery[0]["_id"]
  </code></pre>
  
  <p>Neither of them works!</p>