A
A
amoor2016-08-25 23:35:25
Python
amoor, 2016-08-25 23:35:25

How to open a folder in python?

Not so long ago I came across a problem. Its essence is as follows: you need to write a script that will open a folder and then count how many files there are. I don’t know how to open a folder using python, I thought through open = (''), I tried it - nothing happened, rummaged through Google - I found only deleting folders, not opening them.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Kitaev, 2016-08-25
@spidespidepide

https://docs.python.org/3/library/os.html#os.listdir

E
Evgeniy _, 2016-08-25
@GeneD88

import os
len(next(os.walk(path))[2])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question