Python 3.x 如何解析Python3中的gmail messages.get()批处理响应
我已使用以下代码批处理并执行我的请求:Python 3.x 如何解析Python3中的gmail messages.get()批处理响应,python-3.x,api,gmail-api,Python 3.x,Api,Gmail Api,我已使用以下代码批处理并执行我的请求: batch = BatchHttpRequest() for msg_id in message_ids: batch.add(service.users().messages().get(userId = 'me', id = msg_id['id']), callback = mycallbackfunc) batch.execute() 如何访问每个请求的响应?我已经阅读了文档,但是没有公共方法来获取响应。您可以在回调函数中访问每个请求的响
batch = BatchHttpRequest()
for msg_id in message_ids:
batch.add(service.users().messages().get(userId = 'me', id = msg_id['id']), callback = mycallbackfunc)
batch.execute()
如何访问每个请求的响应?我已经阅读了文档,但是没有公共方法来获取响应。您可以在
回调
函数中访问每个请求的响应,该函数在您的示例中称为mycallbackfunc
:
def process_message(request_id, response, exception):
if exception is not None:
# Do something with the exception
pass
else:
# Do something with the response
pass
batch = BatchHttpRequest()
for msg_id in message_ids:
batch.add(service.users().messages().get(userId = 'me', id = msg_id['id']), callback=process_message)
batch.execute()