I plan to insert string (colon) in between HEX in Python, i.e;
before: AABBCCDDEEFF112233 after: AA:BB:CC:DD:EE:FF:11:22:33
Can anybody here shed some light on how to achieve it.
Regards,
I plan to insert string (colon) in between HEX in Python, i.e;
before: AABBCCDDEEFF112233 after: AA:BB:CC:DD:EE:FF:11:22:33
Can anybody here shed some light on how to achieve it.
Regards,
The answer to your question is here: Pythonic way to insert every 2 elements in a string
You could also use a step i.e. str[::x]
to loop over every 2 characters to achieve this result.
myStr = 'AABBCCDDEEFF112233'
print ':'.join(myStr[i:i+2] for i in range(0, len(myStr), 2))