Python 3 to_bytes函数显示错误的前导零
我正在尝试使用to_bytes函数Python 3 to_bytes函数显示错误的前导零,python,Python,我正在尝试使用to_bytes函数 $ python3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 0x007BEE82BDD9e866B2BD114780A47F2261C684E2.to_bytes(32,'big')
$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 0x007BEE82BDD9e866B2BD114780A47F2261C684E2.to_bytes(32,'big')
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00{\xee\x82\xbd\xd9\xe8f\xb2\xbd\x11G\x80\xa4\x7f"a\xc6\x84\xe2'
前导零的13个字节显然是错误的。为什么会这样?您的号码是20字节,而您要求的是32字节。这将为您提供12个额外的\x00。最后一个是你号码中的00