我正在为 radius 编写一个 rlm_python 模块,它从“Accouting-Request”数据包中获取位置
但是,该位置是二进制格式,
"\001\027\002\025\001+\001\024"
当我尝试使用 struct 解包时
[root@server ~]# python
Python 2.4.3 (#1, May 5 2011, 16:39:10)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from struct import *
>>> unpack('hhl',"\001\027\002\025\001+\001\024" )
Traceback (most recent call last):
File "<stdin>", line 1, in ?
struct.error: unpack str size does not match format
任何想法,我如何解压这些数据?