Python中的十六进制转换 [英] Hexadecimal Conversion in Python

查看:136
本文介绍了Python中的十六进制转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在阅读来自服务器的套接字消息,并且只是

收到这个''....''。现在很明显它的格式错误了。如何用
我用Python转换这些bys,我已经到处寻找但是我确实没有看到很多关于将ptyhon类型转换为其他数据的文档

类型。

任何帮助将不胜感激。

解决方案

DaBeef写道:
< blockquote class =post_quotes>你好,我正在从服务器读取套接字消息,我只是接收这个''....''。现在很明显它的格式错误了。如何在Python中转换这些bys,我已经到处查看但是我没有看到很多关于将ptyhon类型转换为其他数据类型的文档。




服务器应该发送什么(如果你想要解码,你需要知道

)。

然后,查找struct.unpack 。


HTH

Stefan


它返回的数据如0x04。我是python的新手,所以这对我来说是一个痛苦的事情,学会用一种语言来实现这一点,这个语言的llibrary是有点限制的。但我收到了....所以我想转换成原始数据的原因。你也可以在Python中定义一个常量,例如

#define value 0x04

谢谢你的帮助


DaBeef写道:

它返回的数据如0x04。


但你需要知道对方发送的是哪种数据,

即它说的是什么样的协议。

我是python的新手


新的,从套接字/网络编程开始?

勇敢!

所以这是一个<对我来说很痛苦,学习用llibrary有点限制的语言来做这件事。




你的意思是Pythons的图书馆有限吗? br />
你什么都不知道......

但我接受了......所以我想转换为
原始数据。你也可以在Python中定义一个常量,例如
#define value 0x04




你应该看看这里:

<一个rel =nofollowhref =http://docs.python.org/target =_ blank> http://docs.python.org/


也许在这里:

http:// diveintopython。 org / toc / index.html

你的''插座接收器'是什么样的?

Stefan

-

Stefan N?¤we

stefan_AT_naewe_DOT_de


Hello, I am reading in a socket message from a server and am only
receiving this ''....''. Now obviously it is in the wrong format. How
would I convert these bys in Python, I have looked everywhere but I do
not see much documentation on converting ptyhon types to other data
types.
Any Help would be appreciated.

解决方案

DaBeef wrote:

Hello, I am reading in a socket message from a server and am only
receiving this ''....''. Now obviously it is in the wrong format. How
would I convert these bys in Python, I have looked everywhere but I do
not see much documentation on converting ptyhon types to other data
types.



What is the server supposed to send (you need to know that
if you want to decode it).
Then, lookup struct.unpack .

HTH

Stefan


it is returning data such as 0x04. I am new to python so this is a
pain for me, learning to do this in a language whose llibrary is
somewhat limited. But instead I receieve .... So I wnat to convert to
the original data. Also can you define a constant in Python such as
#define value 0x04
Thank-you for your help


DaBeef wrote:

it is returning data such as 0x04.
But you need to know what kind of data the other side is sending,
i.e. what kind of protocol it speaks.
I am new to python
New and starting with socket/network programming ?
Brave!
so this is a
pain for me, learning to do this in a language whose llibrary is
somewhat limited.



You mean Pythons'' library is limited?
You know nothing...

But instead I receieve .... So I wnat to convert to


the original data. Also can you define a constant in Python such as
#define value 0x04



You should look here:

http://docs.python.org/

And probably here, too:

http://diveintopython.org/toc/index.html
What does your ''socket receiver'' look like ?
Stefan
--
Stefan N?¤we
stefan_AT_naewe_DOT_de


这篇关于Python中的十六进制转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆