Programming beginner here. (Python 2.7)
Is there a work around for using more than a single character for Python's ord function?
For example, I have a hex string '\xff\x1a' which I'd like the decimal value for so that I can sum it with other hex strings. However ord only accepts a single hex string character.
Thank you!
Strings are iterable, so you can loop through the string, use ord
and add the results:
your_sum = sum([ord(i) for i in '\xff\x1a'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With