I would like to generate random words from ascii codes. I have tried like that:
import random
liste = [random.randint(33, 127) for i in range(8)]
osman=', '.join(str(x) for x in liste)
a=bytes.fromhex(hex(liste[0])[2:]).decode()
b=bytes.fromhex(hex(liste[1])[2:]).decode()
c=bytes.fromhex(hex(liste[2])[2:]).decode()
d=bytes.fromhex(hex(liste[3])[2:]).decode()
e=bytes.fromhex(hex(liste[4])[2:]).decode()
f=bytes.fromhex(hex(liste[5])[2:]).decode()
g=bytes.fromhex(hex(liste[6])[2:]).decode()
h=bytes.fromhex(hex(liste[7])[2:]).decode()
print(a,b,c,d,e,f,g,h,sep="")
Is there an easier way and how can i develop for more words?
Aucun commentaire:
Enregistrer un commentaire