记录-打印当前目录和其所有子目录中含有name的所有文件
Topic sourceimport osimport timedef ls_l(s): print("%5s | %10s | %10s" % ('Name', 'Size', 'Data')) for file in os.scandir(s): print("%5s | %10s | %10s" % (str(file.name), str(file.stat().st_size/1024)+'KB', str(time.ctime(file.stat().st_ctime))), sep='|')ls_l('./Testsubdir')
├── Testsubdir
│ ├── 1
│ │ └── aa1
│ ├── 2
│ │ └── aa2
│ ├── aa
│ └── ab1
与ls -l 差很多....
- 1
这是QQ昵称
├── Testsubdir
│ ├── 1
│ │ └── aa1
│ ├── 2
│ │ └── aa2
│ ├── aa
│ └── ab1
运行结果: