Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Generate a range of hex numbers in format

i need to create a function in python to generate number in hex from 00:00:00 to FF:FF:FF
the out put can be a string but formated always 6 char seprate by ":"
so it should look like this

0 = 00:00:00
1 = 00:00:01
...
2816 = 00:0B:00
...
16777214 = FF:FF:EF
16777215 = FF:FF:FF

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Try this :

for dec_ldev in range(0,16777215):
    hex_ldev = hex(dec_ldev)[2:].zfill(6)
    print("{}{}{}:{}{}:{}{}".format('',*hex_ldev))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading