python 使用struct.pack 转16进制

s = "317"
#s = s.encode("utf8")
s = hex(int(s))
print(s)
s = int(s, 16)
str2 = struct.pack('>i', s)
#print(s, len(s))
print(str2)

 

posted @ 2021-08-18 10:53  Azuki_op  阅读(773)  评论(0)    收藏  举报