Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在不解释十进制的情况下将 int 值输入位数组,例如:
intvalue = 101
即使转换后保持相同的数字?
strvalue = bitstring.BitArray(intvalue) strvalue == 101
为它加上前缀0b(就像你可以在十六进制整数前面加上0x):
0b
0x
print(0b101) # 5
这就是你如何输入二进制形式的整数(独立于bitarray)。参见例如PEP-3127。
bitarray