Saturday, January 19, 2013

Python strip lstrip rstrip usage

theString = 'saaaay yes no yaaaass' 
print theString.strip('say') 
print theString.strip('say ') # there is a space after "say"
print theString.lstrip('say') 
print theString.rstrip('say') 

Result: 
yes no 
es no 
yes no yaaaass 
saaaay yes no

No comments:

Post a Comment