to_bytes 函数返回奇数

to_bytes function returning odd value

我在使用整数类型的 to_bytes 函数时遇到问题。大于 18200000 的值给我一个奇怪的字节数组作为输出。

我在 raspberry pi 上使用 python 3.5。该值不完全是 18200000,但很接近。

我调用函数的方式是这样的:

frequency = 20000000

print(frequency.to_bytes(7,byteorder='big'))

预期结果将是 b'\x01\x31\x2D\x00'

我得到的是b'\x011-\x00'.

对于可打印的ASCII字符的字节,python将显示相应的字符。 \x31是字符1\x2D-.