[Tutor] stx, etx (\x02, \x03)

richard kappler richkappler at gmail.com
Tue Sep 22 16:07:51 CEST 2015


>
>
>
> > That is *very* unlikely.
>

Perhaps, but I assure you it is what is happening.


>
> > Verify that you deleted the existing mod1.xml. As you open the file in
> > append mode existing faulty lines persist.
>

I did, hence the above assurance.

Here's the modified code:

#!/usr/bin/env python

stx = '\x02'
etx = '\x03'

with open('input/PS06Test_100Packages.xml', 'r') as f1:
    with open('mod1.xml', 'a') as f2:
        for line in f1:
            s = stx + line[:-1] + etx
            f2.write(s)


mod1.xml has the \x02 hex at the beginning of line 1, then line 2 and all
further lines begin with the \x03 hex then the \x02 hex and then the line.

regards, Richard


More information about the Tutor mailing list