<p>我使用<code>windows8</code>,编写代码时使用<code>IDLE</code>。我试着把<code>python</code>连接到<code>mongodb</code>。但是当试图获取集合名时,它会给出一个错误。</p>
<blockquote>
<p>ServerSelectionTimeoutError: localhost:20101: [Errno 10061] No connection could be made because the target machine actively refused it</p>
</blockquote>
<p>这是我收到错误的代码。</p>
<pre><code>from pymongo import MongoClient
connection = MongoClient('localhost',20101)
db = connection['Bhautik']
collection = db['Student']
db.collection_names(include_system_collections=True)
</code></pre>