Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/331.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_Bitstring - Fatal编程技术网

Python 将位int值放入位数组

Python 将位int值放入位数组,python,bitstring,Python,Bitstring,如何将int值输入位数组而不进行解释(如十进制),例如: intvalue = 101 即使在转换后仍保持相同的数字 strvalue = bitstring.BitArray(intvalue) strvalue == 101 在其前面加上0b(就像在十六进制整数前面加上0x): 这就是以二进制形式输入整数的方法(独立于位数组)。见例 print(0b101) # 5

如何将int值输入位数组而不进行解释(如十进制),例如:

intvalue = 101
即使在转换后仍保持相同的数字

strvalue = bitstring.BitArray(intvalue)
strvalue == 101

在其前面加上
0b
(就像在十六进制整数前面加上
0x
):

这就是以二进制形式输入整数的方法(独立于
位数组
)。见例

print(0b101)  # 5