我正在尝试在Python中将纪元日期时间转换为字节数组,但它以10个字节的形式出现,应该是4个字节。
from time import time
curTime = int(time.time())
b = bytearray(str(curTime))
len(b) #comming as 10
有人可以帮我看看哪里出了问题吗?
import struct
from time import time
curTime = int(time())
b = struct.pack(">i", curTime)
len(b) # 4