只获取当前目录下,剔除文件,只要文件夹名称
import os
dbtype_list = os.listdir(sql_dir_war)
for dbtype in dbtype_list:
if os.path.isfile(os.path.join(sql_dir_war,dbtype)):
dbtype_list.remove(dbtype)
本文介绍了一种Python脚本方法,该方法可以列出指定目录下的所有子文件夹名称,同时排除了文件路径。
只获取当前目录下,剔除文件,只要文件夹名称
import os
dbtype_list = os.listdir(sql_dir_war)
for dbtype in dbtype_list:
if os.path.isfile(os.path.join(sql_dir_war,dbtype)):
dbtype_list.remove(dbtype)
1672