Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个传入的 UDP 数据包,类似于:2%W2R.ÃR.Â\Îç½Ý8_5©"ÿ
我想在 python 中将其转换为十六进制。我已经尝试过 binascii 函数,但我得到错误奇数长度字符串。
关于将其转换为十六进制的任何建议?
先感谢您。-VJ
a = "hkfhfksadhfskadl" a.encode("hex")
这应该这样做。
>>> import binascii >>> a = 'aljsd;fkaj;' >>> binascii.hexlify(a) '616c6a73643b666b616a3b3b6b666a7177657234'
如果您收到错误,请在此处发布代码和错误消息。