python struct pack double

妖精的绣舞 提交于 2019-12-11 12:54:37

问题


I want to convert -123.456 into a C double for network transmission in python. So I tried this:

struct.pack('d', -123.456)

I get this as a result:

'w\xbe\x9f\x1a/\xdd^\xc0'

Obviously there is some hex in there, but what is with the w, /, and ^ sprinkled in there?


回答1:


They are, respectively, a "w", "/", and "^". Some byte sequences do correspond to ASCII characters.



来源:https://stackoverflow.com/questions/2008871/python-struct-pack-double

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!