在python上拆分MAC地址

时间:2015-01-08 07:43:54

标签: python-2.7 split mac-address

我有一个MAC地址,我必须稍微操纵一下。

我希望将"FF:FF:FF:FF:FF:FF"转换为"FF FF FF FF FF FF"

怎么做?

感谢您的回答!

2 个答案:

答案 0 :(得分:0)

由于您提到拆分,首先拆分它然后加入它:

' '.join('FF:FF:FF:FF:FF:FF'.split(':'))

答案 1 :(得分:0)

如果是字符串,只需用空格替换所有:个字符:

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