How would I delete everything after a certain character of a string in python? For example I have a string containing a file path and some extra characters. How would I delete e
str.partition:
str.partition
>>> s='abc.zip.blech' >>> ''.join(s.partition('.zip')[0:2]) 'abc.zip' >>> s='abc.zip' >>> ''.join(s.partition('.zip')[0:2]) 'abc.zip' >>> s='abc.py' >>> ''.join(s.partition('.zip')[0:2]) 'abc.py'