Vote count:
0
In my function I have this "try except" situation:
elif (log[i]=='0XDC' or log[i]=='0XDD'):
readable_log = readable_log + READABLE_HEX[log[i]]
numOfCurrency = int(log[i+1],16)
try:
for j in range(0,numOfCurrency):
val = int(log[i+5+j*11],16)*16777216+int(log[i+4+j*11],16)*65536+int(log[i+3+j*11],16)*256+int(log[i+2+j*11],16)
val2 = int(log[i+9+j*11],16)*16777216+int(log[i+8+j*11],16)*65536+int(log[i+7+j*11],16)*256+int(log[i+6+j*11],16)
poll_currency = chr(int(log[i+12+j*11],16))+chr(int(log[i+11+j*11],16))+chr(int(log[i+10+j*11],16))
val = int(val/100)
val2 = int(val2/100)
readable_log = readable_log + 'floated/dispensed: ' + str(val) + ' requested: ' + str(val2) + ': ' + poll_currency
except:
**# Assume that the number of currencies is not given, and is 1. Get values accordingly.**
pass
readable_log = readable_log + '\n'
i = i + numOfCurrency * 11 + 2
How can I calculate the "var" and "var2" in "except" for the cases that "numOfCurrency" is not defined and I want to set it to "1" and calculate var and var2 accordingly.
asked 30 secs ago
Try except handling python
Aucun commentaire:
Enregistrer un commentaire