Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:将字节数组转换回int列表_Python_Arrays - Fatal编程技术网

Python:将字节数组转换回int列表

Python:将字节数组转换回int列表,python,arrays,Python,Arrays,我可以使用以下命令将整数列表转换为字节数组: bytes([17, 24, 121, 1, 12, 222, 34, 76]) Out[144]: b'\x11\x18y\x01\x0c\xde"L' bytes([1, 2, 3]) Out[145]: b'\x01\x02\x03' int.from_bytes(b'\x11\x18y\x01\x0c\xde"L', byteorder='big', signed=False) Out[146]: 1231867543503643212

我可以使用以下命令将整数列表转换为字节数组:

bytes([17, 24, 121, 1, 12, 222, 34, 76])
Out[144]: b'\x11\x18y\x01\x0c\xde"L'
bytes([1, 2, 3])
Out[145]: b'\x01\x02\x03'
int.from_bytes(b'\x11\x18y\x01\x0c\xde"L', byteorder='big', signed=False)
Out[146]: 1231867543503643212
我现在想要的是将字节数组字符串恢复到其原始列表中。有没有一个简单的python函数可以做到这一点?我发现:

bytes([17, 24, 121, 1, 12, 222, 34, 76])
Out[144]: b'\x11\x18y\x01\x0c\xde"L'
bytes([1, 2, 3])
Out[145]: b'\x01\x02\x03'
int.from_bytes(b'\x11\x18y\x01\x0c\xde"L', byteorder='big', signed=False)
Out[146]: 1231867543503643212

我不太清楚这里发生了什么。转换是如何发生的,输出意味着什么。因此,如果有人能提供一些上下文或见解,我将不胜感激

您可以使用
list()

测试代码: 结果:
您可以使用
list()
获得比我想象的更大的数组。如果可能,您还可以解释int.from_字节中发生了什么
int.frombytes()
生成一个整数。如果传递大量字节,它可能会很大。