Problem with the strip string method
Jorge Godoy
jgodoy at gmail.com
Sun Mar 2 11:49:42 EST 2008
Colin J. Williams wrote:
> Return a copy of the string with the
> leading and trailing characters removed.
^^^^^^^^^^^^^^^^^^^^
> Only the last two examples below behave
> as expected.
They all looks OK to me.
> [Dbg]>>> 'ab$%\n\rcd'.strip('%')
> 'ab$%\n\rcd'
No "%" at the beginning or end of string. Nothing changed.
> [Dbg]>>> 'ab$%cd'.strip('$')
> 'ab$%\n\rcd'
No "$" at the beginning or end of string. Nothing changed. I believe that
you didn't copy this from the standard input due to the presence of "\r\n"
on the answer...
> [Dbg]>>> 'ab$%cd'.strip('$')
> 'ab$%cd'
No "$" at the beginning or end of string. Nothing changed.
> [Dbg]>>> ' ab$%cd '.strip('$')
> ' ab$%cd '
No "$" at the beginning or end of string. Nothing changed.
> [Dbg]>>> ' ab$%cd '.strip('%')
> ' ab$%cd '
No "%" at the beginning or end of string. Nothing changed.
More information about the Python-list
mailing list