strip() 2.4.4

linuxprog linuxprog at gmail.com
Thu Jun 21 15:42:03 CEST 2007


Stephen R Laniel a écrit :
> On Thu, Jun 21, 2007 at 06:23:01AM -0700, Nick wrote:
>   
>> Why is there a apostrophe still at the end?
>>     
>
> Is it possible that you actually have whitespace at the end
> of the line? So then strip() is looking for an apostrophe at
> the end of the line, not finding it, and therefore not
> stripping it?
>
>   
that should work for you ?

f1 = open('in.txt', 'r')

for line in f1:
   print line.rsplit(':')[4].rstrip().strip("'"),

maybe you got some \n \r at the end of each line
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070621/faec9960/attachment.html>


More information about the Python-list mailing list