Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13951

how do I turn a hex byte into an integer?

$
0
0

the error that gets thrown is

    print(chr(hex(int(sel,16))))          ^^^^^^^^^^^^^^^^^^^^^TypeError: 'str' object cannot be interpreted as an integer

the code given is

for i in range(0,len(text),2):    sel = "0x"+text[i:i+2]    #print(sel)    print(chr(hex(int(sel,16))))

so how do I get the hex bytes to be an integer, for chr to output the correct character?

edit: i figured it out.


Viewing all articles
Browse latest Browse all 13951

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>