Answers for "python find file in current directory"

11

python get current file location

import os
os.path.dirname(os.path.abspath(__file__))
Posted by: Guest on May-11-2020
1

python get files in directory

from pathlib import Path
for txt_path in Path("/path/folder/directory").glob("*.txt"):
  print(txt_path)
Posted by: Guest on November-30-2020
0

python get files in directory

(_, _, filenames) = os.walk(mypath).next() #if you are confident that the walk will return at least one value
Posted by: Guest on August-31-2021

Code answers related to "python find file in current directory"

Python Answers by Framework

Browse Popular Code Answers by Language