【发布时间】:2011-01-09 20:43:20
【问题描述】:
我的 python 应用程序中有这样的字符串:
test1/test2/foo/
每次得到这样的字符串,我都想减少它,从尾部开始减少,直到到达第一个“/”。
test1/test2/
更多示例:
foo/foo/foo/foo/foo/ => foo/foo/foo/foo/
test/test/ => test/
how/to/implement/this => how/to/implement/
如何在 python 中实现?
提前致谢!
【问题讨论】: