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

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -