469,269 Members | 1,006 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,269 developers. It's quick & easy.

Removing a spaces from the tailing end of a string

440 256MB
Hi,

I have a string str1 = 'Pnt ', I would like to remove the spaces from the tailing end of a string.

I/P :
str1 = 'Pnt '

O/P :

'Pnt'

Is there method available to trim the string in leading and tailing end?

I/P :
str1 = ' Pnt '

O/P :

'Pnt'

Thanks
PSB
Mar 26 '07 #1
4 2154
dshimer
136 Expert 100+
Expand|Select|Wrap|Line Numbers
  1. >>> astring=' some text '
  2. >>> astring.strip()
  3. 'some text'
  4.  
Also check out lstrip(), and rstrip().
Mar 26 '07 #2
psbasha
440 256MB
Sorry,I have fixed it .

After working with more and more into the Python.I forgot the method ,saying that there is a "strip() " method available

-PSB
Mar 26 '07 #3
bartonc
6,596 Expert 4TB
Sorry,I have fixed it .

After working with more and more into the Python.I forgot the method ,saying that there is a "strip() " method available

-PSB
You can always:
Expand|Select|Wrap|Line Numbers
  1. >>> help(str)
for a quick reminder of all the things that strings know how to do.
Mar 27 '07 #4
psbasha
440 256MB
Thanks Barton,It is really helpful.

-PSB
Mar 27 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by hokiegal99 | last post: by
6 posts views Thread by jalkadir | last post: by
11 posts views Thread by gopal srinivasan | last post: by
12 posts views Thread by Magix | last post: by
1 post views Thread by Shaw | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.