Wednesday, June 24, 2009

Python string strip function..

I just realized a super blunder, I have committed all my life

url = 'abcdc.com'
print url.strip('.com')
Expect: abcdc
Resut: abcd

Instead try
url.rsplit('.com', 1)

strip function takes in an array of characters and chops any pattern of characters in the array.. :(

No comments: