首页 > 代码库 > int-整数+bool-布尔功能介绍
int-整数+bool-布尔功能介绍
int
#1.当前整数用二进制表示的最小位数
# age = 50 # v = age. # print(v)
def bit_length(self): # real signature unknown; restored from __doc__ """ int.bit_length() -> int Number of bits necessary to represent self in binary. >>> bin(37) ‘0b100101‘ >>> (37).bit_length() 6 """ return 0
#2.获取当前数据的字节表示
# age = 15 # v = age.to_bytes(4,b # v1 = age.to_bytes(4, # print(v) # print(v1) #执行结果 #b‘\x00\x00\x00\x0f‘ # b‘\x0f\x00\x00\x00‘
def to_bytes(self, length, byteorder, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ """ int.to_bytes(length, byteorder, *, signed=False) -> bytes Return an array of bytes representing an integer. The integer is represented using length bytes. An OverflowError is raised if the integer is not representable with the given number of bytes. The byteorder argument determines the byte order used to represent the integer. If byteorder is ‘big‘, the most significant byte is at the beginning of the byte array. If byteorder is ‘little‘, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder‘ as the byte order value. The signed keyword-only argument determines whether two‘s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised. """ pass
布尔
0 false 其他是true
空 false 其他是true
int-整数+bool-布尔功能介绍
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。