How to translate type numbers

50 20 10 45

and so on

Decimal 8 bits, Decimal 32 bits, Octal 8 bits, Octal 32 bits, Hexadecimal 8 bits, Hexadecimal 32 bits

?

PS found a link of this type

Hexadecimal 8 bits http: //0x1f.0xd.0x53.0x24

I want to make a script that will make such links.

  • 2
    You need this result: 'http://' + '.'.join(map(hex, map(int, "50 20 10 45".split()))) # 'http://0x32.0x14.0xa.0x2d' ? - gil9red
  • Yes, but I still need Octal and Decimal - Alex Firsov

1 answer 1

 numbers = [int(c) for c in "50 20 10 45".split()] print('http://' + '.'.join(map(hex, numbers))) # http://0x32.0x14.0xa.0x2d print('http://' + '.'.join(map(str, numbers))) # http://50.20.10.45 print('http://' + '.'.join(map(oct, numbers))) # http://0o62.0o24.0o12.0o55