首页 > 解决方案 > Python如何检索数组中的数据

问题描述

首先我不确定这是否是一个数组。但这是 pyzbar 解码二维码图像

>>> from pyzbar.pyzbar import decode
>>> from PIL import Image
>>> barcode = decode(Image.open('qr111.png'))
>>> print(barcode)
[Decoded(data='812', type='QRCODE', rect=Rect(left=1166, top=306, width=336, height=336), polygon=[Point(x=1166, y=306), Point(x=1166, y=642), Point(x=1502, y=642), Point(x=1502, y=306)])]

我想专门检索数据的值“812”,我该怎么做?我试过 print(barcode[Decoded(data)]) 无济于事。

标签: pythonarrays

解决方案


这会给你你想要的:

barcode[0].data

这一切都在源代码中。


推荐阅读