美文网首页
Python-循环遍历文件夹

Python-循环遍历文件夹

作者: 西博尔 | 来源:发表于2017-04-16 22:23 被阅读172次
    for root,dirs,files in os.walk(payloadPath):
        for tempFile in files:
        path = os.path.join(root,tempFile)
        # print "文件路径 =" +path
        with open(path,"rb") as file:
                for line in file:
                      if (line.find("xxxx")>0):
                          print "******存在******"
                          #写日志
                           filePath = path+"\n"
                           fileList.append(filePath)
                           break
    

    相关文章

      网友评论

          本文标题:Python-循环遍历文件夹

          本文链接:https://www.haomeiwen.com/subject/ailzattx.html