【发布时间】:2015-04-08 14:34:47
【问题描述】:
#! /usr/bin/python -tt
import os
def searchFile(path1,ext1,fileName1):
pathList = []
for root, dirs, files in os.walk(path1):
for file in files:
if file.endswith(ext1):
pathList.append(os.path.join(root,file))
print "-----The file is present under the below path------\n"
for ele in pathList:
if fileName1 in ele:
print ele
def main():
path = raw_input("Please enter the path you wish to spider. Also make sure that the files/subfolders have the correct permissions.\n")
ext = raw_input("Enter the extension you wish to search/ find. Eg: For class files enter .class / For text file enter .txt \n")
fileName = raw_input("Enter the filename without extension. Eg For example.class, input only 'example'\n")
searchFile(path,ext,fileName)
if __name__ == '__main__':
main()
对于普通文件/子文件夹,它可以正确获取路径/文件名,但是当爬取“jars”时,python 脚本不会返回任何内容。 如何使上述脚本通过罐子扫描?
【问题讨论】:
-
您必须取消归档 jar。扫描解压后的文件夹,返回路径……必要时删除文件夹
标签: python python-2.7 jar scripting ipython