Python Forum
Search file with *filename* python 3.8
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search file with *filename* python 3.8
#9
(Dec-22-2019, 12:06 AM)lastyle Wrote: lets assume there is a directory that matches my searchpattern, how do i reflect that ?
In the last code with os.walk() it only search for files(in all sub-folders).
So if a folder it's named folderbestfile it will not be in result,
but files with bestfile names in this folder will be in result as wanted.

If need in a other cases to check if something is a file or folder can use.
os.path.isfile(path)
os.path.isdir(path)
Or if using pathlib.
my_file.is_file()
my_file.is_dir()
Reply


Messages In This Thread
Search file with *filename* python 3.8 - by lastyle - Dec-19-2019, 09:07 PM
RE: Search file with *filename* python 3.8 - by snippsat - Dec-22-2019, 07:38 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020