2021-09-07 2021-09-07 使用pathlib 1 2 3 4 5 6 7 8 9 from pathlib import Path path = Path('.') dirs = [e for e in path.iterdir() if e.is_dir()] for dir in dirs: print(dir) 使用os.walk 1 2 3 import os output = [dI for dI in os.listdir('foo') if os.path.isdir(os.path.join('foo',dI))] print(output) 前一篇 centos8 开机自动运行dhclient 后一篇 使用openvpn作为网关上网故障排除
说些什么吧!