def replace_ext(file_path, new_ext):
    if not new_ext.startswith(os.extsep):
        new_ext = os.extsep + new_ext
    index = file_path.rfind(os.extsep)
    return file_path[:index] + new_ext
>>> replace_ext('one/two/three.four.doc', '.html')
dataset/ETHPy150Open PolicyStat/docx2html/docx2html/core.py/replace_ext