Forum >> Programmazione Python >> Calcolo scientifico >> decodificare una stringa

Pagina: 1

Buonasera,

premetto che ho iniziato da poco a usare Python. Mi sono imbattuta in questo problema: ho una stinga in un elemento uint8[] che corrisponde a valori da 0 a 255.


eehggehhdeagefhfddbcadbecbcdcdaciffabbfchaaddbdcecafabbedecccececdbfdehhfibcaabfddcgegaabacddfcbcbfeedfdccd`dccf`bag`dfceceddad`cefhggbfjde`bicfggffddfcgcefhehcddfchdgcfacdb`fegfifgdahceidiehjjghhddafhgdaggegaefkihngihhejifehjikjdkgjgighechgehde`dcb`dadddaddccfcdebdcacbcacafddecdadbacedbbadbcbc`a`bbccgdbfgdebekifidghdegbehfhfdfgihigifbcighidc`dcbefcccgceaddcfhdhfbdbbcdehddcccfddbceaecacbbb`bfegidfbfddbd`cfdegfchfeaeeidcbccgfbh``efcfgdhkhhhjimkkhffiljjnlhmgicbfeffgeefdbeggfdbaegfdeidcbfdhdjiihdhhhcc`dihfhifahehgdehhigjihhllemmlimgfjwrfmlnliflldbcfiijfhhhaehhhlmllqoqojlmnkfllorrqstgnirqmejppnkhqmjiijildghgehdihjnnnlkfklkkhiiaffgmkgejijhdihhhkefgddjklihjoqfnnqiimqmomnlnlikhedcgfhgjkihgighfhjfkikkhghmohhhacghehfeeghlkihdgfieh`cfddbachchcabadeeegedffdejkhkmrmpqslnkolrrsklqpxtsqpxsuyxxrqpprurrmqrslnifklckpkntvmplkjkjihhkdilknkincliibfjicfhkkjbdgchgklfeeiedhgiigihhijghggihchfehhhieoifknjnqqqihpomhklmlljkjgfkiehdchffgjhldefcgehcfgcfcaabhdegbgeddfchdgfbcehahehhiiighhfijgekiilhifhgiieigfhhjgehdfeedhhhkjidedhhifgdackjmhljgddhddchiklklgeehhfiejifhfhjihiegegifhffjikhighihieifhkhjehihghhjmgjlhjhcdhfebhichkjjgacbdfhaeeeefcigcagehf`hfkhnccebdeghhffgicgikdcccbdegjkifgbdgegeedeecafijbhkhcfcffgcecimlgefdbcac`edhejfhacfeecegihhcgkjjkjhhigeabadcgedgfdhebfcdchdbadeeihghedihiigfabcebbdbbdfhhhgeeehegehegf`adeehhecdahh`eehgebcfghdfegcdfaeabgbdgd^eacfgihhgcdabbdc`aachjhebcbebefgbhfggedbcfceaddbebdba_`bbed`cbfbdfjbe`cdaecdbggdfabbaaab`bdccgcfbebddddefch
come faccio a decodificarla? Grazie

Mi rispondo da sola...........







pixel=eehggehhdeagefhfddbcadbecbcdcdaciffabbfchaaddbdcecafabbedecccececdbfdehhfibcaabfddcgegaabacddfcbcbfeedfdccd`dccf`bag`dfceceddad`cefhggbfjde`bicfggffddfcgcefhehcddfchdgcfacdb`fegfifgdahceidiehjjghhddafhgdaggegaefkihngihhejifehjikjdkgjgighechgehde`dcb
x=[ord(c) for c in pixel]# una lista

Well, by using below python script you can do this.




hex_string = "eehggehhdeagefhfddbcadbecbcdcdaciffabbfchaaddbdcecafabbedecccececdbfdehhfibcaabfddcgegaabacddfcbcbfeedfdccd`dccf`bag`dfceceddad`cefhggbfjde`bicfggffddfcgcefhehcddfchdgcfacdb`fegfifgdahce idiehjjghhddafhgdaggegaefkihngihhejifehjikjdkgjgighechgehde`dcb`dadddaddccfcdebdcacbcacafddecdadbacedbbadbcbc`a`bbccgdbfgdebekifidghdegbehfhfdfgihigifbcighidc`dcbefcccgceaddcfhdhfbdbbcdehddcccfdd bceaecacbbb`bfegidfbfddbd`cfdegfchfeaeeidcbccgfbh``efcfgdhkhhhjimkkhffiljjnlhmgicbfeffgeefdbeggfdbaegfdeidcbfdhdjiihdhhhcc`dihfhifahehgdehhigjihhllemmlimgfjwrfmlnliflldbcfiijfhhhaehhhlmllqoq ojlmnkfllorrqstgnirqmejppnkhqmjiijildghgehdihjnnnlkfklkkhiiaffgmkgejijhdihhhkefgddjklihjoqfnnqiimqmomnlnlikhedcgfhgjkihgighfhjfkikkhghmohhhacghehfeeghlkihdgfieh`cfddbachchcabadeeegedffdejkhkmrmpqslnk olrrsklqpxtsqpxsuyxxrqpprurrmqrslnifklckpkntvmplkjkjihhkdilknkincliibfjicfhkkjbdgchgklfeeiedhgiigihhijghggihchfehhhieoifknjnqqqihpomhklmlljkjgfkiehdchffgjhldefcgehcfgcfcaabhdegbgeddfchd gfbcehahehhiiighhfijgekiilhifhgiieigfhhjgehdfeedhhhkjidedhhifgdackjmhljgddhddchiklklgeehhfiejifhfhjihiegegifhffjikhighihieifhkhjehihghhjmgjlhjhcdhfebhichkjjgacbdfhaeeeefcigcagehf`hfkhnccebdeghhffgic gikdcccbdegjkifgbdgegeedeecafijbhkhcfcffgcecimlgefdbcac`edhejfhacfeecegihhcgkjjkjhhigeabadcgedgfdhebfcdchdbadeeihghedihiigfabcebbdbbdfhhhgeeehegehegf`adeehhecdahh`eehgebcfghdfegcdfaeabgbdgd^eacfgi hhgcdabbdc`aachjhebcbebefgbhfggedbcfceaddbebdba_` bbed`cbfbdfjbe`cdaecdbggdfabbaaab`bdccgcfbebddddefch"




# Split the string into chunks of two characters each

hex_chunks = [hex_string[i:i+2] for i in range(0, len(hex_string), 2)]




# Convert each chunk to decimal and then to bytes

decoded_bytes = bytes([int(chunk, 16) for chunk in hex_chunks])




# Decode the bytes to a string

decoded_string = decoded_bytes.decode('utf-8')




print(decoded_string)




Thanks



Pagina: 1



Esegui il login per scrivere una risposta.