提取文件名并且做分隔

item ="2017-08-22_13_02_16.wav"

_,audioname = os.path.split(item)

filestr, postfix = os.path.splitext(audioname)

#提取文件名

# print(filestr)

[label,name] = filestr.split('-',1)

print audioname #2017-08-22_13_02_16.wav

print filestr #2017-08-22_13_02_16

print postfix #.wav

print label #2017

print name #08-22_13_02_16

你可能感兴趣的:(提取文件名并且做分隔)