Probleme bei if abfrage
Verfasst: Sonntag 18. Oktober 2020, 13:13
Hallo,
ich versuche seit stunden eine if abfrage zu basteln bekomme es aber leider nicht hin.
wenn die variable data None enthält, soll das script es mit print in die console schreiben und nicht das script abbrechen.
hätte da einer ein kleines beispiel für mich bitte?
ich versuche seit stunden eine if abfrage zu basteln bekomme es aber leider nicht hin.
wenn die variable data None enthält, soll das script es mit print in die console schreiben und nicht das script abbrechen.
hätte da einer ein kleines beispiel für mich bitte?
Code: Alles auswählen
while continue_reading:
# Scan for cards
(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
# If a card is found
if status == MIFAREReader.MI_OK:
print "Card detected"
# Get the UID of the card
(status,uid) = MIFAREReader.MFRC522_Anticoll()
# If we have the UID, continue
if status == MIFAREReader.MI_OK:
# Print UID
print "Card read UID: %s,%s,%s,%s" % (uid[0], uid[1], uid[2], uid[3])
# This is the default key for authentication
key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]
# Select the scanned tag
MIFAREReader.MFRC522_SelectTag(uid)
# Authenticate
status = MIFAREReader.MFRC522_Auth(MIFAREReader.PICC_AUTHENT1A, 8, key, uid)
# Check if authenticated
if status == MIFAREReader.MI_OK:
data = MIFAREReader.MFRC522_Read(8)
print "Data:", data
MIFAREReader.MFRC522_StopCrypto1()
text = "".join(chr(x) for x in data)
print text
print data
print uid
else:
print "Authentication error"