10001000100010001000100010001000 # your number
& 11111111000000000000000000000000 # 0xff000000
= 10001000000000000000000000000000 # then >> 24
10001000
10001000100010001000100010001000 # your number
& 00000000111111110000000000000000 # 0xff0000
= 00000000100010000000000000000000 # then >> 16
0000000010001000 # etc.
您可以使用您的输入,在屏蔽后对其进行位移,然后将其重新组合在一起:
输出
如果低于3.6,可以使用
"{:b}.{:b}.{:b}.{:b}".format(four,three,two,one)
而不是f-strings
。你知道吗免责声明:这使用应用于某些二进制位移位的Python int to binary string?:
相关问题 更多 >
编程相关推荐