Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 没有getitem属性_Python - Fatal编程技术网

Python 没有getitem属性

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

我正在尝试将Pagseguro整合到巴西的支付服务中,类似于PayPal

但是,我不知道如何从服务发送给我的通知中访问数据。这是我的代码:

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