[Tutor] Tutor Digest, Vol 38, Issue 10
Alan Gauld
alan.gauld at btinternet.com
Fri Apr 6 16:47:56 CEST 2007
"Jay Mutter III" <jmutter at uakron.edu> wrote
>> Can you try printing the string repr just before the test.
>> Or even the last 6 characters:
>>
>> print repr(line[-6:])
>> if line.endswith('No: \n')
>> line = line.strip()
> Alan using your suggestion with the code aove here is the print out:
>
> jay-mutter-iiis-computer:~/documents/ToBePrinted jlm1$ python
> test.py
> 'andal\r'
> ' No.\r'
Just to be picky, the code I posted used a colon and a space
whereas the repr shows a period and no space. And it's using \r
so what happens if you run it again with:
print repr(line[-6:])
if line.endswith('No.\r'):
line = line.strip()
Clutching at straws,
Alan G.
More information about the Tutor
mailing list