1 import os
 2 import re
 3 
 4 zifu = ['<audio >]
 5 count = 0
 6 rootdir = 'D:\\LittleWorld\\src\\audio\\common'
 7 list = os.listdir(rootdir)                      #列出文件夹下所有的目录与文件
 8 for i in range(0,len(list)):
 9     path = os.path.join(rootdir,list[i])
10     if os.path.isfile(path):
11 
12         if path.find('mp3') != -1:
13             count = count + 1
14             xiabiao = path.find("audio")
15             newstr = path[xiabiao:len(path)]
16             path = zifu[0] + str(count) + zifu[1] + newstr + zifu[2]
17             print(path)
18         else:
19             # print("该文件不是MP3格式:%s"%path)
20             pass

 

相关文章:

  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
猜你喜欢
  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2021-08-31
相关资源
相似解决方案