samedi 4 mars 2023

random alphanumeric string into hexadecimal in Python [duplicate]

I'm trying to turn an alphanumeric string into a hexadecimal number.

The following code works as intended...

A = "f8g9dsf9s7ff7s9dfg98d9fg97s06s6df5"
B = int(A, 16)

When I try create the alphanumeric dynamically it breaks and doesn't get converted to hexadecimal number...

A = ''.join(random.choices(string.ascii_lowercase + string.digits, k=34))
B = int(A, 16)

Thanks for the help, extremely new to Python.




Aucun commentaire:

Enregistrer un commentaire