import os
import sys
import textwrap
string123="00505661e418005056618f67080045000086000040004011c1bd1e1e1e321e1e1e3cc0e62118007200000800000000000100000c298a92ba000c29f914ea080045000054c757400040015a93464646144646461e080031e3470d000142bdaf5600000000cb27030000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637"
j=0
i = 0
string1234 = ''
while i < len(string123):
string1234 = string1234+' '+string123[i:i+2]
i+=2
final = string1234.strip()
final1= '\n'.join(textwrap.wrap(final, 47))
print final
f=open("final.txt","w")
f.write(final1)
f.close
f=open("final.txt","r")
g=f.readlines()
my_list=["000","001","002","003","004","005","007","008","009"]
line_new=""
for lines in g:
while j < len(my_list):
line_new = my_list[j]+" "+ lines
print line_new
lines+=1
j+=1
This script actually runs two characters together in an “S” and adds a space. He then enters a new line for every 47 characters and copies the output to final.txt.
final.txt as follows:
00 50 56 61 e4 18 00 50 56 61 8f 67 08 00 45 00
00 86 00 00 40 00 40 11 c1 bd 1e 1e 1e 32 1e 1e
1e 3c c0 e6 21 18 00 72 00 00 08 00 00 00 00 00
01 00 00 0c 29 8a 92 ba 00 0c 29 f9 14 ea 08 00
45 00 00 54 c7 57 40 00 40 01 5a 93 46 46 46 14
46 46 46 1e 08 00 31 e3 47 0d 00 01 42 bd af 56
00 00 00 00 cb 27 03 00 00 00 00 00 10 11 12 13
14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23
24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33
34 35 36 37
I would like to add 000to the first line, then 001to the second line and 003to the third line, etc.
So, I created a list with these values, and I'm trying to iterate through the strings along with the list items.
my_list=["000","001","002","003","004","005","007","008","009"]
line_new=""
for lines in g:
while j < len(my_list):
line_new = my_list[j]+" "+ lines
print line_new
lines+=1
j+=1
But this is adding all the items to the list on the first line. The first element of the list should be added to the beginning of the first line, which means the second, third, etc.