![](/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.