Search and replace operation
问题内容:
I have a list which has URL values like:
http://farm6.static.flickr.com/5149/5684108566_aed8b9b52d_s.jpg
How can I change the _s
in the end to _m
for all occurrences?
问题答案:
Try this:
str = "http://farm6.static.flickr.com/5149/5684108566_aed8b9b52d_s.jpg"
str = str.replace("_s","_m")
If you want to be sure that only the las part is changed and you know all are
.jpg
files you can use:
str = "http://farm6.static.flickr.com/5149/5684108566_aed8b9b52d_s.jpg"
str = str.replace("_s.jpg","_m.jpg")
To give some more context and avoid changes on the middle of the url.