![](/img/trans.png)
[英]Is this {'': [ {}, {}, {} ]} Dictionary of List of a Dictionary? How can I Split the inside values so I can print/process them separately?
[英]How can I list the paths of all (sub)folders and put them separately in a list?
我有一個程序,在其中生成許多文件夾和文件。 在主文件夾中,我希望代碼查找其中的所有文件夾,並將它們單獨保存在列表中。 所以使用self._list[0]
我想獲得一個文件夾路徑。 我是Python的新手,但我知道已有一些路徑打印行,但這些都沒有給我提供路徑。 使用此代碼我得到文件夾的名稱,但我還需要路徑:
self._folderList=os.listdir(self._mainFolderPath)
您可以使用以下代碼手動將路徑附加到文件夾名稱:
self._folderList=[self._mainFolderPath + '\\' + folder_name for folder_name in os.listdir(self._mainFolderPath)]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.