擅长:python、mysql、java
<p>digitaloceanrestapi与python库不同(python库可能在幕后使用API)。你知道吗</p>
<p>如果您阅读<a href="https://github.com/koalalorenzo/python-digitalocean#checking-the-status-of-the-droplet" rel="nofollow noreferrer">library docs</a>,您将看到您需要使用<code>status</code>:</p>
<pre><code>actions = droplet.get_actions()
for action in actions:
action.load()
# Once it shows complete, droplet is up and running
print(action.status)
</code></pre>
<p>一旦有了<code>complete</code>状态,你的水滴就上升了。我不知道这是否会阻塞并等待您的液滴完成,因此您可能需要执行以下操作:</p>
<pre><code>import time
running = False
while not running:
print('Waiting 1s for droplet to start up...')
time.sleep(1)
actions = droplet.get_actions()
for action in actions:
action.load()
if action.status == 'complete':
running = True
</code></pre>