Answers for "how to get directory of file in python"

18

python list files in current directory

import os

files = os.listdir('.')
print(files)
for file in files:
  # do something
Posted by: Guest on November-04-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 "how to get directory of file in python"

Python Answers by Framework

Browse Popular Code Answers by Language