Skip to content

Instantly share code, notes, and snippets.

@mjseeley
Last active August 29, 2015 14:08
Show Gist options
  • Save mjseeley/f6deacc8cbb5f5dfb655 to your computer and use it in GitHub Desktop.
Save mjseeley/f6deacc8cbb5f5dfb655 to your computer and use it in GitHub Desktop.
Convert Decimal MAC address to hex MAC address (123.123.123.123.123.123 -> 00AABBCCDDEE)
# Function/arguments: decmactohexmac(decmac)
# Description: Convert Decimal MAC address to hex MAC address (123.123.123.123.123.123 -> 00AABBCCDDEE)
# Returns: MAC address in hex format without delimiters
def decmactohexmac(decmac): #
decmac = decmac.split(".")
hexmac = ''.join(str(hex(int(i)).lstrip('0x')).zfill(2) for i in decmac).upper()
return hexmac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment