Python 3.x Python3 Stripe API用于获取所有客户电子邮件

Python 3.x Python3 Stripe API用于获取所有客户电子邮件,python-3.x,stripe-payments,Python 3.x,Stripe Payments,StripeAPI似乎不允许我们一次性获得所有客户信息。以下代码可以打印1000个客户的电子邮件 import stripe stripe.api_key = "secret" customer_dict = stripe.Customer.list(limit=1000) print(customer_dict) for i in range(len(customer_dict)): print(customer_dict.data[i]['email'])

StripeAPI似乎不允许我们一次性获得所有客户信息。以下代码可以打印1000个客户的电子邮件

import stripe

stripe.api_key = "secret"

customer_dict = stripe.Customer.list(limit=1000)

print(customer_dict)

for i in range(len(customer_dict)):

  print(customer_dict.data[i]['email'])
结果:

abc@gmail.com
def@gmail.com
xyz@gmail.com
etc.
但假设我有无限数量的Stripe客户,我如何打印他们的所有电子邮件

如果我用他们的自动寻呼器,它会一直打印出最近的10封电子邮件

customer_dict = stripe.Customer.list(limit=10)

for customer in customer_dict.auto_paging_iter():

  # print(customer_dict)

  for i in range(len(customer_dict)):

    print(customer_dict.data[i]['email'])

谢谢。

您不能使用高于100的限制,自动分页迭代器可能是您在这里想要的,但您需要执行以下操作,而不是您正在执行的操作:

for customer in customer_dict.auto_paging_iter(limit=100):
  print(customer['email'])
customer_dict作为一个数组,只包含最初的10个对象。如果要为所有客户创建一个包含所有电子邮件的数组,可以执行以下操作:

customer_emails = [c['email'] for c in customer_dict.auto_paging_iter(limit=100)]

…或类似内容。

您不能使用高于100的限制,自动分页迭代器可能是您在此处想要的,但您需要执行以下操作,而不是您正在执行的操作:

for customer in customer_dict.auto_paging_iter(limit=100):
  print(customer['email'])
customer_dict作为一个数组,只包含最初的10个对象。如果要为所有客户创建一个包含所有电子邮件的数组,可以执行以下操作:

customer_emails = [c['email'] for c in customer_dict.auto_paging_iter(limit=100)]
…或类似的