471,624 Members | 1,928 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,624 software developers and data experts.

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 2224
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
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.