[Easysnmp] python snmp IF-MIB::ifPhysAddress messy code, parsing mac address messy code

Reference content

Session_api
MAC address displaying in binary #14

Solution

Add parameters when setting up snmp sessionuse_sprint_value

use_sprint_value-Set to True to use the return value of the get and getnext methods formatted by the sprint_value library. This will result in certain data types being returned in a non-canonical format. Note: The value returned by this option set may not be suitable for setting operations

which is:


from easysnmp import Session
def snmpSessionFunc():
  """ 
    use_sprint_value=True 
  """
  return Session(hostname="<client_ip>", community="<community>", version=<version_number>, use_sprint_value=True)

Guess you like

Origin blog.csdn.net/qq_22227087/article/details/109223633