title: Convert MAC to aa:bb:cc:dd:11:22
body: <p>I'm creating a SNMP program to list interfaces (with ip, mask and mac) of devices. I'm using NetSnmp to get the macaddress but the output looks like this ('\x00PV\xaf\x00v',)</p>
  
  <p>This is the SNMP request:</p>
  
  <pre><code>    oidmac = netsnmp.Varbind("ifPhysAddress."+i)
  
      mac = netsnmp.snmpget(
          oidmac, 
          Version = 2, 
          DestHost = sys.argv[2], 
          Community = sys.argv[1])
  </code></pre>
  
  <p>Info about the code ...</p>
  
  <ul>
  <li><code>sys.argv[1]</code> = Community string  </li>
  <li><code>sys.argv[2]</code> = IP of the SNMP agent</li>
  <li><code>i</code> = a variable with the interface ID.</li>
  </ul>
  
  <p>How can I convert the string to an MAC address in format <code>aa:bb:cc:dd:11:22</code> ? </p>