0
import os
path = 'D:/folder1/folder2/folder3/file.txt'
folders=[]
while 1:
path,filename=os.path.split(path)
if filename!="":
folders.append(filename)
else:
if path!="":
folders.append(path)
print folders
break
如何從路徑只打印一個文件夾名?例如僅打印文件夾2或僅打印文件夾1在python上打印一個特定的文件夾名稱