當前位置: 首頁>>代碼示例>>Python>>正文


Python uos.mkdir方法代碼示例

本文整理匯總了Python中uos.mkdir方法的典型用法代碼示例。如果您正苦於以下問題:Python uos.mkdir方法的具體用法?Python uos.mkdir怎麽用?Python uos.mkdir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在uos的用法示例。


在下文中一共展示了uos.mkdir方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: makedirs

# 需要導入模塊: import uos [as 別名]
# 或者: from uos import mkdir [as 別名]
def makedirs(path):
    _path = ''
    if path[0] == '/':
        path = path.strip('/').split('/')
        for i in path:
            _path += '/' + i
            try:
                os.mkdir(_path)
            except:
                pass
    else:
        path = path.split('/')
        for i in path:
            _path += i
            try:
                os.mkdir(_path)
                _path += '/'
            except:
                pass 
開發者ID:m5stack,項目名稱:UIFlow-Code,代碼行數:21,代碼來源:utils.py

示例2: mkdir

# 需要導入模塊: import uos [as 別名]
# 或者: from uos import mkdir [as 別名]
def mkdir(self, directory, exists_okay=False):
        """Create the specified directory.  Note this cannot create a recursive
        hierarchy of directories, instead each one should be created separately.
        """
        # Execute os.mkdir command on the board.
        command = """
            try:
                import os
            except ImportError:
                import uos as os
            os.mkdir('{0}')
        """.format(
            directory
        )
        self._pyboard.enter_raw_repl()
        try:
            out = self._pyboard.exec_(textwrap.dedent(command))
        except PyboardError as ex:
            # Check if this is an OSError #17, i.e. directory already exists.
            if ex.args[2].decode("utf-8").find("OSError: [Errno 17] EEXIST") != -1:
                if not exists_okay:
                    raise DirectoryExistsError(
                        "Directory already exists: {0}".format(directory)
                    )
            else:
                raise ex
        self._pyboard.exit_raw_repl() 
開發者ID:scientifichackers,項目名稱:ampy,代碼行數:29,代碼來源:files.py

示例3: save

# 需要導入模塊: import uos [as 別名]
# 或者: from uos import mkdir [as 別名]
def save(self):
        # Create config_dir if do not exists
        try:
            uos.stat(self.config_dir)
        except OSError:
            uos.mkdir(self.config_dir)
        with open('{}/{}.json'.format(self.config_dir, self.name), 'w') as fp:
            json.dump(self.data, fp) 
開發者ID:IBM-Developer-Korea,項目名稱:developer-badge-2018-apps,代碼行數:10,代碼來源:util.py

示例4: mkdir

# 需要導入模塊: import uos [as 別名]
# 或者: from uos import mkdir [as 別名]
def mkdir(path):
    try:
        uos.mkdir(path)
    except OSError as e:
        pass 
開發者ID:fadushin,項目名稱:esp8266,代碼行數:7,代碼來源:test_server.py

示例5: init

# 需要導入模塊: import uos [as 別名]
# 或者: from uos import mkdir [as 別名]
def init(root_path='/test'):
    print("Initializing from {}...".format(root_path))
    mkdir('{}'.format(root_path))
    write('{}/index.html'.format(root_path), "<html><body>Hello World!</body></html>")
    mkdir('{}/foo'.format(root_path))
    write('{}/foo/test.txt'.format(root_path), "test")
    mkdir('{}/foo/bar'.format(root_path))
    write('{}/foo/bar/test.js'.format(root_path), "{'foo': \"bar\"}")
    write('{}/foo/bar/test.css'.format(root_path), "html") 
開發者ID:fadushin,項目名稱:esp8266,代碼行數:11,代碼來源:test_server.py


注:本文中的uos.mkdir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。