python - stripping a pattern from the end of the string -


i want see if file test_100.webp exists , @ file test.yaml. therefore, need strip pattern "_100.webp" end. tried use code below , giving me issues.

 i, image in enumerate(images_in_item):         if image.endswith("_100.webp"):             image_strip = image.rstrip(_100.webp)             snapshot_markup = os.path.join(image_strip + 'yaml') 

do this:

suffix = '_100.webp' if image.endswith(suffix):     image_strip = image[:-len(suffix)]     snapshot_markup = os.path.join(image_strip + 'yaml') 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -