gpt4 book ai didi

python - PYSNMP 代理在解码 Hexa 值后返回换行符作为输出

转载 作者:行者123 更新时间:2023-12-04 09:46:54 25 4
gpt4 key购买 nike

面对 pysnmp 代理返回值的奇怪问题。
PYSNMP 代理接收字符串格式为 "0a0a0a0a0a0a0a0a0a" .
在 MIB 中,OID 表示为 HEXA STRING。
当尝试使用 rfc1902.OctetString(hexValue=str_temp) 返回字符串时,输出为空,因为六值(0a0a0a)被解码为新行 (\n)人物。

SNMPv2-SMI::example.154.12.1.0 = STRING: "

"

伪代码:
str="0a0a0a0a0a0a0a0a"
After Return using rfc1902.OctetString(str) or rfc1902.OctetString(hexaValue=str)

异常输出:
SNMPv2-SMI::example.154.12.1.0 = Hex-STRING: 0A 0A 0A 0A 0A 0A 0A 0A 

有人可以帮助我,如何将原始输出解码或发送到 hexa 字符串以获得上述所需的输出。

最佳答案

for oid, val in varBinds:
print(oid.prettyPrint(),' = ',val.prettyPrint())

关于python - PYSNMP 代理在解码 Hexa 值后返回换行符作为输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62082050/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com