@TOC c_str = path.toStdString();
std::string::iterator ite=c_str.end()-1;
//查找‘/’数量
while(ite != c_str.begin())
{
if(*ite == '/')
{
num++;
}
ite--;
len++;
//有两个以上‘/’,退出当前循环
if(num>1)
continue;
}
if(num>1)
{
//从后往前删除元素,直到‘/’
c_str.erase(c_str.end()-len, c_str.end());
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200612204234912.png)