assets
root
container1
container2
container3
container4
container5
I编写了以下函数,该功能即可获取路径,并且甚至在容器内显示了所有容器。我要实现的是将容器的名称放在资产/根中,而没有更深的容器。
import os
from azure.storage.filedatalake import DataLakeServiceClient
connection_string = os.getenv("AZURE_STORAGE_CONNECTION_STRING")
data_lake_service_client = DataLakeServiceClient.from_connection_string(conn_str=connection_string)
filesystem_client = data_lake_service_client.get_file_system_client(file_system="assets")
paths = filesystem_client.get_paths(path="root")
for path in paths:
if path.is_directory:
print("\t" + path.name)
GET_CONTAINERS(PATH =“”) 或者 list_containers(路径=“”)
仅列出它们
置换更改以下代码行:
paths = filesystem_client.get_paths(path="root")
to
paths = filesystem_client.get_paths(path="root", recursive=False)
基于可用的文档
here
,默认值recursive
参数为True
,这就是为什么您也看到子文件夹。