# int类型转bytes
# 指定4个字节的bytes
length = 4
args = 333
# 指定大端
res = args.to_bytes(length, byteorder='big')
print(res)  # b'\x00\x00\x01M'
# 指定小端
res = args.to_bytes(length, byteorder='little')
print(res)  # b'M\x01\x00\x00'
打赏

发表评论

邮箱地址不会被公开。 必填项已用*标注