# string manipulations
# striping characters out of strings
aUrl = "http://www.example.com"
# strip, lstrip, rstrip only remove characters
# on the either edge (strip), the left edge (lstrip),
# and the right edge(rstrip)
print aUrl.strip("htp:/w.com")
#outputs:
# example
print aUrl.lstrip("htp:/")
#outputs:
# www.example.com
print aUrl.rstrip(".com")
#outputs:
# http://www.example
# to strip out all occurances
# of a character use replace()
print aUrl.replace('m', "")
#outputs:
# http://www.exaple.co
A python example based blog that shows how to accomplish python goals and how to correct python errors.
Showing posts with label rstrip. Show all posts
Showing posts with label rstrip. Show all posts
Thursday, September 17, 2009
Python - string stripping
Subscribe to:
Posts (Atom)