Skip to content

Instantly share code, notes, and snippets.

@licsber
Created April 29, 2020 02:54
Show Gist options
  • Select an option

  • Save licsber/05d2a7b45e25274d516807f4a0c6e0e7 to your computer and use it in GitHub Desktop.

Select an option

Save licsber/05d2a7b45e25274d516807f4a0c6e0e7 to your computer and use it in GitHub Desktop.
计算文件夹中的文件数和目录数 用于坚果云同步
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