<p>从问题中的boto文件中:</p>
<pre><code>Response Syntax
{
'NatGateways': [
{
'CreateTime': datetime(2015, 1, 1),
'DeleteTime': datetime(2015, 1, 1),
'FailureCode': 'string',
'FailureMessage': 'string',
'NatGatewayAddresses': [
{
'AllocationId': 'string',
'NetworkInterfaceId': 'string',
'PrivateIp': 'string',
'PublicIp': 'string'
},
],
'NatGatewayId': 'string',
'ProvisionedBandwidth': {
'ProvisionTime': datetime(2015, 1, 1),
'Provisioned': 'string',
'RequestTime': datetime(2015, 1, 1),
'Requested': 'string',
'Status': 'string'
},
'State': 'pending'|'failed'|'available'|'deleting'|'deleted',
'SubnetId': 'string',
'VpcId': 'string',
'Tags': [
{
'Key': 'string',
'Value': 'string'
},
]
},
],
'NextToken': 'string'
}
</code></pre>
<p>响应是<code>dict</code>,包含<code>NatGateways</code>列表。由于响应是<code>dict</code>,因此不使用<code>object.property</code>表示法访问响应的属性;而是<code>object['property']</code></p>
<p>这个循环应该工作:</p>
<pre class="lang-py prettyprint-override"><code>for NAT in NATs['NatGateways']:
print('deleted NAT gateways: ' + NAT['NatGatewayId'])
...
</code></pre>