Aug-12-2019, 10:04 AM
hello there to be brief I would like to change 6 hexa characters but in several files
I explain myself I designed this code:
roughly the next step is to re-open file2.dat and increment the hexa value of 1 is to write it in file3.dat ect........
I'm locked on a loop apparently.
thank you in advance for your help
I explain myself I designed this code:
fichier1 = "fichier.dat"
with open(fichier1, "rb") as fs:
contenu = fs.read() # le contenu est de type "bytes" (=octets)
octet1 = bytes.fromhex('7AEB02') # octet à chercher
octet2 = bytes.fromhex('7AEB03') # octet à mettre à la place
index = contenu.find(octet1)
if index<0:
print("Octet non trouvé!")
else:
print("Octet cherché se trouve à l'index:", index)
contenu = contenu[:index] + octet2 + contenu[index+1:]
fichier2 = "fichier2.dat"
with open(fichier2, "wb") as fd:
fd.write(contenu)the.dat file contains 7AEB02 then replace with 7AEB03 and write the new file to file2.datroughly the next step is to re-open file2.dat and increment the hexa value of 1 is to write it in file3.dat ect........
I'm locked on a loop apparently.
thank you in advance for your help
