Ejemplo 1: Python convierte binario / hexadecimal / decimal en binario / hexadecimal / decimal
## First install the module coden with pip in cmd
# pip install coden
## import module
import coden
## Convert
# Binary to Decimal
ans = coden.bin_to_int(number)
# Binary to Hexadecimal
ans = coden.bin_to_hex(number)
# Hexadecimal to Decimal
ans = coden.hex_to_int(number)
# Hexadecimal to Binary
ans = coden.hex_to_bin(number)
# Decimal to Binary
ans = coden.int_to_bin(number)
# Decimal to Hexadecimal
ans = coden.int_to_hex(number)
# Thank you!
Ejemplo 2: Python convierte hexadecimal en binario
my_hexdata = "1a"
scale = 16 # equal to hexadecimal
bin(int(my_hexdata, scale))[2:].zfill(len(my_hexdata)*4)
# By changing the parameter of the zfill function we allow for any length of
# hexadecimal code, which is more useful when using this code.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)