Skip to content

Instantly share code, notes, and snippets.

@wilkice
Created January 19, 2022 10:19
Show Gist options
  • Save wilkice/1f8e0428702380a55dbadaca16351852 to your computer and use it in GitHub Desktop.
Save wilkice/1f8e0428702380a55dbadaca16351852 to your computer and use it in GitHub Desktop.
[16 进制转换] #dev

16 进制需要先转为 10 进制的 byte,然后 byte 和 str 相互转换

Python

# ascii str to hex str
"hello".encode().hex()  # '68656c6c6f'

# hex str to ascii
bytes.fromhex("68656c6c6f").decode()  # "hello"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment