简体   繁体   中英

Azure Data Lake Storage Gen2 create directory if not exists in python

How to check whether the directory exists. if not create a directory

filesystem_client.create_directory("my_directory")

will create a directory, but i want to achieve something like this:

if not os.path.exists("my_directory"):
   filesystem_client.create_directory("my_directory")

A directory will automatically be created if it does not exist, however, if you're referring to a file system/container then from my knowledge there does not seem to be a pythonic way of doing that, however, you can just wrap the code within a try except block, if it does not exist it will get caught in the except block and you can then create the file system/container.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM