<pre class="markdow-doc">
import os def dir_walk(dirname): filelist = [] for root, dirs, files in os.walk(dirname):#root dir files 都是类 for name in dirs: filelist.append(os.path.join(root, name)) print(filelist) return filelist dirname = r'D:\BaiduMusic\virus'#r是转义,要不就用双斜杠 print(dir_walk(dirname))