nfcpy读取文本数据而不是序列号

2024-10-04 01:24:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我有下面的python代码,每次在扫描仪上触摸rfid卡时都使用nfcpy打印序列号

它工作得很好,但我不确定如何读取其他信息,特别是我放在卡上的自定义文本数据

有人知道如何使用下面的代码读取文本数据吗

from nfc import ContactlessFrontend
import time

def connected(tag):
    ident = ''.join('{:02x}'.format(ord(c)) for c in tag.identifier)
    print(ident)
    return False

clf = ContactlessFrontend('usb')
while True:
    clf.connect(rdwr={'on-connect': connected})
    time.sleep(1)

Tags: 数据代码文本importtimetagconnectrfid
1条回答
网友
1楼 · 发布于 2024-10-04 01:24:15

因此,NFC工具将Ndef数据写入NFC标记

https://nfcpy.readthedocs.io/en/latest/topics/get-started.html

An NFC Forum Tag can store NFC Data Exchange Format (NDEF) Records in a specifically formatted memory region. NDEF data is found automatically and wrapped into an NDEF object accessible through the tag.ndef attribute. When NDEF data is not present the attribute is simply None.

 assert tag.ndef is not None
 for record in tag.ndef.records:
     print(record)

NDEF Uri Record ID '' Resource 'http://nfcpy.org'

等等

相关问题 更多 >