python 从文件路径中截取所需文件名

# file:'/shipu/projects/mtcnn/Test/data/image/2002/11/02/big/img_976.jpg'

#方法一
imageID_F = file[38:68]
imageID,_ = imageID_F.split('.')
imageIN = imageID_F.split('.')
print(imageID[0])

 

#方法二

imageID_F = file[38:68]
imageID,_ = imageID_F.split('.')
print(imageID)

得到想要的图片名 imageID:'2002/11/02/big/img_976' 

你可能感兴趣的:(python)