Python compare char to hex -
>>> var = 'g' >>> print hex(ord(var)) 0x67 >>> print hex(ord(var)) == 0x67 false
why isn't true in python 2.7?
best way compare 'g' hex value 0x67?
hex
returns string, comparing number. either
ord(var) == 0x67
or
hex(ord(var)) == "0x67"
(the first 1 less error-prone, it's case insensitive)
Comments
Post a Comment