I'm trying to find the maximum value in a string of hex numbers. My approach is to convert is to tokenize the string, convert that list of tokens into ints and then take the max value.
The string is formatted like so:
'\x1e\x00\x00\x00\xf0\x0f184203308373388492761797873987'
I cannot control the format because it is the output of the Python binding of the LZ4 algorithm.
Other similar answers on SO don't have mixed types or use escape characters in a string with many hex numbers.
So, how do I turn that into a list such as:
[0x1e, 0x00, 0x00, ...]
Thank you for your help.
lz4.compress()? If so, the string isn't a list of hex numbers.lz4.compress("z"*10) == '\n\x00\x00\x00\xa0zzzzzzzzzz', for example.lz4.dumps("z"*10) == '\n\x00\x00\x00\xa0zzzzzzzzzz'. I agree that the two digits after the "x" are hexadecimal, but which characters get them and which don't is a fluke of encoding. Look atlz4.dumps("\xff"*10), for example. Are you simply after max(ord(x) for x in s)?