How to remove a path prefix in python?

前端 未结 4 516
走了就别回头了
走了就别回头了 2020-12-28 11:36

I wanted to know what is the pythonic function for this :

I want to remove everything before the wa path.

p = path.split(\'/\')
counter         


        
4条回答
  •  清歌不尽
    2020-12-28 12:13

    >>> path = '/book/html/wa/foo/bar/'
    >>> path[path.find('/wa'):]
    '/wa/foo/bar/'
    

提交回复
热议问题