prateek prateek - 1 year ago 76
Python Question

Search and replace operation

I have a list which has URL values like:

How can I change the
in the end to
for all occurrences?

Answer Source

Try this:

str = ""
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 = ""
str = str.replace("_s.jpg","_m.jpg")

To give some more context and avoid changes on the middle of the url.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download