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

Alan Gauld alan.gauld at btinternet.com
Sun Sep 27 21:30:01 CEST 2015


On 22/09/15 17:32, Oscar Benjamin wrote:

>> with open('input/PS06Test_100Packages.xml', 'r') as f1:
>>      with open('mod1.xml', 'a') as f2:
>>          for line in f1:
>>              s = '\x02' + line[:-1] + '\x03\n'

A further possibility is the [-1] is not stripping
the full EOL on your system.

Try using

line.rstrip()

instead, it should remove all non text characters.

Another random thought.
I'm playing catch up since I just returned from a week's vacation...


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list