Valueerror: Invalid Literal For Int() With Base 16: ''
I trying to run the following script but encounter this error. array.append([int(h[i:i + 2], 16) for i in (0, 2, 4)]) What is wrong in my code?
Solution 1:
You are trying to parse strings as numbers in hexadecimal, where each string is two characters from h. That means your string h needs to be long enough to have content for each of the substrings.
For instance, if h is '1234', then
h[0:2] == '12'
h[2:4] == '34'
h[4:6] == ''Your code can parse '12' and '34' as numbers in hex, but it can't parse '', so it would raise an exception.
Post a Comment for "Valueerror: Invalid Literal For Int() With Base 16: ''"