PyDocs

Nav

Python Runtime Services

bytearray.fromhex

builtins

classmethod of bytearray
  • bytearray.fromhex(string, /)
Create a bytearray object from a string of hexadecimal numbers.

Spaces between two numbers are accepted.
Example:
    bytearray.fromhex('B9 01EF') -> bytearray(b'\\xb9\\x01\\xef')
Changed in 3.7, 3.14
  • 3.7: bytearray.fromhex() now skips all ASCII whitespace in the string, not just spaces.
  • 3.14: bytearray.fromhex() now accepts ASCII bytes and bytes-like objects as input.
1 Example
>>> bytearray.fromhex('2Ef0 F1f2  ')
bytearray(b'.\xf0\xf1\xf2')
from the Python docs
See Also
No see-alsos for builtins/bytearray.fromhex
0 Notes
No notes for bytearray.fromhex