enums - 数据包字段枚举为字符串
问题描述
我想获取数据包字段的字符串表示形式,例如:
pkt[BOOTP].op == 'BOOTREPLY'
到目前为止,我发现的唯一麻烦的方法是:
pkt[BOOTP].fields_desc[0].i2repr(pkt[BOOTP], 2)
还有什么想法吗?
解决方案
您可以使用sprintf
pkt.sprintf("%BOOTP.op%")
推荐阅读
- c++ - 在 C++ 中强制删除 std::shared_ptr
- r - 在 r 中创建带有凸包的图
- sql-server - 将 3 个表连接到一个结果集中
- reactjs - react-router-dom 中的第二个和后续路由没有被渲染?
- excel - Excel VBA 代码,用于在一个单元格中进行多项选择的数据验证 - 用于多列
- xml - 使用 XML 和 XSL 创建 SVG 折线图
- mysql - 从表中查找不匹配的用户
- python-3.x - UnicodeEncodeError:“ascii”编解码器无法对位置 2-7 中的字符进行编码:序数不在范围内(128)
- javascript - 为什么我的函数在延迟后不删除元素?
- math - 计算向量端点