1
revotu 2017 年 6 月 27 日 Python 文件操作相关问题: http://www.revotu.com/python-file-operation-related-issues.html
>>> import os >>> DIR = '/tmp' >>> print len([name for name in os.listdir(DIR) if os.path.isfile(os.path.join(DIR, name))]) 如统计文件夹数量,用 os.path.isdir(path)做判断语句。 |
2
hemoely 2017 年 6 月 27 日
用 python 套一个 shell
|
3
yucongo 2017 年 6 月 28 日
from pathlib import Path # Py3 自带
dir_path = '.' print(len(list(Path(dir_path).iterdir())) |