hexadecimal_string = "AB" byte_array = bytearray.fromhex(hexadecimal_string) print(byte_array)
>>> b'xdexadxbexef'.hex() 'deadbeef'
>>> bytes.fromhex('deadbeef') b'xdexadxbexef'