Last active
June 29, 2021 00:17
-
-
Save yuliji/a826b5b58854acc4ce09524bbc476500 to your computer and use it in GitHub Desktop.
[string to hex] Convert string to hex format 0xab123 #python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> b = '区块链是金融系统的未来'.encode('utf-8') | |
>>> b | |
b'\xe5\x8c\xba\xe5\x9d\x97\xe9\x93\xbe\xe6\x98\xaf\xe9\x87\x91\xe8\x9e\x8d\xe7\xb3\xbb\xe7\xbb\x9f\xe7\x9a\x84\xe6\x9c\xaa\xe6\x9d\xa5' | |
>>> int.from_bytes(b, byteorder='big', signed=False) | |
26580042452449738111737693352426092008374866632327585440351958788959384868658597 | |
>>> hex(int.from_bytes(b, byteorder='big', signed=False)) | |
'0xe58cbae59d97e993bee698afe98791e89e8de7b3bbe7bb9fe79a84e69caae69da5' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment