擅长:python、mysql、java
<p>您可以返回<code>list</code>个<code>dict</code>:</p>
<pre><code>customers = []
for customer in doc.findall('.//Customer'):
customer_dict = {}
customer_dict['number'] = customer.findtext('CustomerNumber')
customer_dict['first_name'] = customer.findtext('FirstName')
customer_dict['last_name'] = customer.findtext('LastName')
# ad nauseum
customers.append(customer_dict)
webservice.close()
return customers
</code></pre>
<p>或者创建一个<code>Customer</code>类来处理这个问题,然后返回<code>list</code>个客户实例。你知道吗</p>