2018-04-26|2018-04-26 Use glob to filter folders under a path
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)
import glob
import ostarget_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
- http://python.jobbole.com/81552/
推荐阅读
- 二、NSUserDefaults
- window.navigator.userAgent用来区分设备和浏览器
- 每日一词|每日一词 | cause
- pymysql|pymysql 封装操作
- iOS|iOS -Cannot synthesize weak property because the current deployment target does n
- Linux-Shell命令|Linux-Shell命令 -- fdisk/mkfs/mount/fuser (硬盘分区/挂载)
- Asp.net|System.Globalization.DateTimeFormatInfo.InvariantInfo
- TCP|TCP 协议如何保证可靠传输
- 批量insertOrUpdate或replace-into使用useGeneratedKeys报错简单分析
- 谈谈UI设计师及想从事UI设计的事