python结构包双 [英] python struct pack double
本文介绍了python结构包双的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在python中将-123.456转换成C双用于网络传输.所以我尝试了这个:
I want to convert -123.456 into a C double for network transmission in python. So I tried this:
struct.pack('d', -123.456)
我得到了这个结果:
'w\xbe\x9f\x1a/\xdd^\xc0'
显然那里有一些十六进制,但是 w、/和 ^ 洒在那里是什么?
Obviously there is some hex in there, but what is with the w, /, and ^ sprinkled in there?
推荐答案
它们分别是w"、/"和^".一些字节序列确实对应于 ASCII 字符.
They are, respectively, a "w", "/", and "^". Some byte sequences do correspond to ASCII characters.
这篇关于python结构包双的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文