remove the last character or the newline character?
- From: "Daniel Mark" <danielmarkhot@xxxxxxxxx>
- Date: 28 Sep 2006 07:14:43 -0700
Hello all:
I have the following snippet:
In [1]: fileName = 'Perfect Setup.txt\n'
In [2]: fileName = fileName[0:len(fileName)-1)] # remove the '\n'
character
In [3]: fileName
Out[3]: 'Perfect Setup.txt'
Question one:
Does python provide any function that can remove the last character of
a string?
I don't know whether or not the method I used is efficient
Question two:
Does python provide any function that can remove the newline character
from a string if it exists?
Thank very much!
-Daniel
.
- Follow-Ups:
- Re: remove the last character or the newline character?
- From: Tim Chase
- Re: remove the last character or the newline character?
- From: Duncan Booth
- Re: remove the last character or the newline character?
- From: Bruno Desthuilliers
- Re: remove the last character or the newline character?
- From: Georg Brandl
- Re: remove the last character or the newline character?
- From: John Salerno
- Re: remove the last character or the newline character?
- Prev by Date: startswith() and endswith() for re's would be more intuitive
- Next by Date: Re: Questions on Using Python to Teach Data Structures and Algorithms
- Previous by thread: startswith() and endswith() for re's would be more intuitive
- Next by thread: Re: remove the last character or the newline character?
- Index(es):
Relevant Pages
|