下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。
内存溢出小编现在分享给大家,也给大家做个参考。
#!/user/bin/python # -*- Coding:utf8 -*- import Basic import os ##################################################### ######## input #### folder = "D:\安装包" folder = folder.encode("gbk") ######## Global #### fileList = [] allfiles = [] tree = [] level = 0 ##################################################### try: if folder is None or len(folder) == 0: folder = os.curdir if os.path.isdir(folder): childfile = os.Listdir(folder) fileList = ["%s" % (folder+os.path.sep+f) for f in childfile] node = {'file':folder,'level':level} tree.append(node) while fileList is not None and len(fileList) > 0: allfiles.append(""+fileList[0]) if os.path.isdir(fileList[0]): childfile = os.Listdir(fileList[0]) if childfile is not None and len(childfile) > 0: fileList = fileList + ["%s" % (fileList[0]+os.path.sep+ft) for ft in childfile] else: pass else: pass fileList.pop(0) print "\n".join(["%s" % f for f in allfiles]) else: print 'not folder,no child' except Exception,x: print x
以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的Python抓取文件夹的所有文件,包括子文件夹和子文件夹的文件全部内容,希望文章能够帮你解决Python抓取文件夹的所有文件,包括子文件夹和子文件夹的文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)