我有一些像这样的文件路径:
G:folder1folder2folder3folder4folder5fold2/197320-6-10-0.wav
如何提取最后一个文件夹和文件名如下:
fold2/197320-6-10-0.wav
可能的解决方案是使用split()
函数。
text_string = r'''G:folder1folder2folder3folder4folder5fold2/197320-6-10-0.wav'''
data = text_string.split("\")[-1]
print(data)
打印
fold2/197320-6-10-0.wav