这将打印当前目录的所有子目录:
print [name for name in os.listdir(".") if os.path.isdir(name)]我不确定您在做什么
split("-"),但是也许这段代码可以帮助您找到解决方案?如果需要目录的完整路径名,请使用
abspath:
print [os.path.abspath(name) for name in os.listdir(".") if os.path.isdir(name)]请注意,这些代码片段将仅获取直接子目录。如果需要子目录等,则应使用
walk其他建议的子目录。



