Convertir une liste en hexa en python

H25 -  
heyquem Messages postés 808 Statut Membre -
Bonjour,

je suis débutant en Python. comment convertir une liste de chaine de caracteres en hexa ?

merci :)

1 réponse

  1. heyquem Messages postés 808 Statut Membre 131
     
    bonsoir,

    for c in 'abcd':
        o = ord(c)
        print c,o
        print hex(o),type(hex(o))
        print
    
    
    print ''.join(hex(ord(c)) for c in 'abcd')

    résultat:

    a 97
    0x61 <type 'str'>
    
    b 98
    0x62 <type 'str'>
    
    c 99
    0x63 <type 'str'>
    
    d 100
    0x64 <type 'str'>
    
    0x610x620x630x64
    0