Pages

Mar 24, 2015

[Python] strip vs. replace

Here are some examples showing the differences between the function of "strip()" and "replace()" in Python.
Be careful! strip() will delete any character in the beginning or end of the word that matches "any" character in the word we put in the strip function. For example, we put "& quot;" as a parameter into strip(), then any character matches ('&', 'q', 'u', 'o', 't', ';') will be deleted. It doesn't have to be exactly the same "string."

2 comments: