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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -