How to remove a path prefix in python?

A better answer would be to use os.path.relpath:

http://docs.python.org/3/library/os.path.html#os.path.relpath

>>> import os
>>> full_path="/book/html/wa/foo/bar/"
>>> relative_path="/book/html"
>>> print(os.path.relpath(full_path, relative_path))
'wa/foo/bar'

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)