我正在使用Gmail API访问我的Gmail数据,以及Google Python API客户端。
根据文档,在Python中获取邮件附件的示例代码是这个。但是,我尝试使用相同的代码时出现错误:
AttributeError: 'Resource'对象没有属性'user'
我遇到错误的代码行:
message = service.user().messages().get(userId=user_id, id=msg_id).execute()
于是我尝试通过替换user()
,来使用users()
:
message = service.users().messages().get(userId=user_id, id=msg_id).execute()
但我在 for part in message['payload']['parts']
中没有得到 part['body']['data']
。