Python程序教程

您现在的位置是:首页 >  Python

当前栏目

Python – 0b、0o、0x

Python,0b,0o,0x
2025-04-11 08:58:01 时间

大家好,又见面了,我是你们的朋友全栈君。

a = 0b010
b = 0o010
c = 0x010
print(type(a),a)
print(type(b),b)
print(type(c),c)
#-------------
print(0b010&0b111)
print(0b001|0b010)
print(0b010^0b100)
print(~0b001)    #原码->补码->求原码(原码的值+符号位即为最后的真值)
#--------------
print(bin(0x10))
print(hex(0b10))
print(oct(0b10))
print(int(0x10))

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/152549.html原文链接:https://javaforall.cn