Python 没有getitem属性
我正在尝试将Pagseguro整合到巴西的支付服务中,类似于PayPal 但是,我不知道如何从服务发送给我的通知中访问数据。这是我的代码:Python 没有getitem属性,python,Python,我正在尝试将Pagseguro整合到巴西的支付服务中,类似于PayPal 但是,我不知道如何从服务发送给我的通知中访问数据。这是我的代码: notification_code = request.POST['notificationCode'] pg = PagSeguro(email="testPerson@gmail.com", token="token") notification_data = pg.check_notification(notification_code) print
notification_code = request.POST['notificationCode']
pg = PagSeguro(email="testPerson@gmail.com", token="token")
notification_data = pg.check_notification(notification_code)
print notification_data['status']
在las行中,我收到以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'PagSeguroNotificationResponse' object has no attribute '__getitem__'
自述文件中的文档似乎与代码不匹配。它看起来不像是一个字典,而是一个具有与自述文件中的字典键匹配的属性的对象 因此,如果您只需将打印通知_数据['status']更改为以下内容,则这应该可以工作:
print notification_data.status
自述文件中的文档似乎与代码不匹配。它看起来不像是一个字典,而是一个具有与自述文件中的字典键匹配的属性的对象 因此,如果您只需将打印通知_数据['status']更改为以下内容,则这应该可以工作:
print notification_data.status