python 遍历文件夹下所有mp3

#python

import os
import shutil

g = os.walk('files')

for path, d, files in g:
    for filename in files:
        file = os.path.join(path, filename)
        if 'mp3' in file:
            print file
            shutil.move(file, 'mp3/' + filename)

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐