I have used this below code. But As it contains a lots of files and folders its taking lots of time.
for localDirname, localDirnames, localFilenames in os.walk('.'):
for localFilename in localFilenames:
if fullFileName == localFilename :
print "File found"
If you are not needing to recursively walk a remote directory os.listdir
could provide a faster option.
for f in os.listdir('.'):
if fullFileName in f:
print "File found"
You can try
with open
or os.stat
. You can also keep a list of folders where it can be for trying each.
Also, it will always be quicker to use @Evert's idea.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.