2018-04-26 Use glob to filter fo
作者:
猪迹 | 来源:发表于
2018-04-26 16:03 被阅读0次
Usage
- Determine a path as a file
os.path.isfile()
- Determine a path as a folder
os.path.isdir()
- Search under a path
glob.glob()
- Get file name from a given path
os.path.basename(sub_file)
Code snap to filter under a path
import glob
import os
target_folder = "xxxxx"
arr_dir = []
if os.path.exists(target_folder):
for sub_file in glob.glob(target_folder + "/*"):
if os.path.isdir(sub_file):
arr_dir.append(sub_file)
References
本文标题:2018-04-26 Use glob to filter fo
本文链接:https://www.haomeiwen.com/subject/ehxmlftx.html
网友评论