Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- path = "/path/to/dir/"
- dirs = os.listdir(path)
- for dir in dirs:
- p1 = os.path.join(path, dir)
- files = os.listdir(p1)
- for file in files:
- # открытие файла, запись куда-то и т.п.
- a = open(os.path.join(p1, file), "r")
- # ...
- $ tree test
- test
- ├── a
- │ └── 001.txt
- └── b
- └── 001.txt
- import glob
- for pathname in glob.glob('test/*/*.txt'):
- with open(pathname) as f:
- print(f.read(), end="")
Add Comment
Please, Sign In to add comment