Created
April 29, 2020 02:54
-
-
Save licsber/05d2a7b45e25274d516807f4a0c6e0e7 to your computer and use it in GitHub Desktop.
计算文件夹中的文件数和目录数 用于坚果云同步
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| dirs = [] | |
| files = [] | |
| def walk(file): | |
| if os.path.isdir(file): | |
| dirs.append(file) | |
| for f in os.listdir(file): | |
| walk(file + '/' + f) | |
| else: | |
| files.append(file) | |
| walk('.') | |
| print(len(dirs)) | |
| print(len(files)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment