获得discuz7.2 目录下所有文件,并写到txt
1 # -*- coding: utf-8 -*- 2 3 4 import os 5 6 7 fileList = [] 8 dzList = [] 9 10 def GetFileList(path): 11 List = [] 12 for root,dirs,files in os.walk(path): 13 for fn in files: 14 List.append(root + os.sep + fn) 15 return List 16 17 def GetUrlPath(List): 18 UrlPathList = [] 19 f = open("discuz72.txt","w") 20 for ll in List: 21 f.write( "/".join(ll[ll.find("dz72")+len("dz72"):].split(os.sep))) 22 f.write(os.linesep) 23 24 if __name__ == "__main__": 25 GetUrlPath(GetFileList(r"E:\xampp\htdocs\dz72"))
我的本地网站根目录是htdocs,discuz7.2存储在dz72目录下。