I'm trying to represent a given string in hex values, and am failing.
I've tried this:
# 1
bytes_str = bytes.fromhex("hello world")
# 2
bytes_str2 = "hello world"
bytes_str2.decode('hex')
For the first one I get "ValueError: non-hexadecimal number found in fromhex() arg at position 0" error
For the second I get that there's no decode
attribute to str
. It's true but I found it here so I guessed it's worth a shot.
My goal is to print a string like this: \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...
Thanks for the help!