Issue
How can I get the number of files in a certain folder using pathlib ?
from pathlib import Path
fileDir = Path("C:/Users/Jonas/Desktop/Test")
Solution
You could use .glob()
or .rglob()
:
from pathlib import Path
fileDir = Path("C:/Users/Jonas/Desktop/Test")
excelFiles = fileDir.rglob('*.xl*')
print(len(list(excelFiles)))
>>> 3
Answered By - Maurice Meyer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.