在 python 上拆分 MAC 地址

Splitting MAC address on python

我有一个 MAC 地址需要稍微修改一下。

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

如何做到?

感谢您的回答!

既然你提到拆分,那就先拆分再合并:

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

如果是字符串,只需将所有 : 个字符替换为 space:

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