Search code examples
python-2.7splitmac-address

Splitting MAC address on python


I have a MAC address that I have to manipulate just a little.

I wish to convert "FF:FF:FF:FF:FF:FF" to "FF FF FF FF FF FF".

How can it be done?

Thanks for the answers!


Solution

  • If it's a string, simply replace all : characters with a space:

    >>> mac = 'FF:FF:FF:FF:FF:FF'
    >>> spacemac = mac.replace(':',' ')
    >>> spacemac
    'FF FF FF FF FF FF'