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


Python genericpath._unicode方法代碼示例

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


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

示例1: abspath

# 需要導入模塊: import genericpath [as 別名]
# 或者: from genericpath import _unicode [as 別名]
def abspath(path):
    """Return an absolute path."""
    if not isabs(path):
        if isinstance(path, _unicode):
            cwd = os.getcwdu()
        else:
            cwd = os.getcwd()
        path = join(cwd, path)
    return normpath(path)

# realpath is a no-op on systems without islink support 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:13,代碼來源:macpath.py

示例2: abspath

# 需要導入模塊: import genericpath [as 別名]
# 或者: from genericpath import _unicode [as 別名]
def abspath(path):
        """Return the absolute version of a path."""
        if not isabs(path):
            if isinstance(path, _unicode):
                cwd = os.getcwdu()
            else:
                cwd = os.getcwd()
            path = join(cwd, path)
        return normpath(path) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:ntpath.py

示例3: abspath

# 需要導入模塊: import genericpath [as 別名]
# 或者: from genericpath import _unicode [as 別名]
def abspath(path):
    """Return an absolute path."""
    if not isabs(path):
        if isinstance(path, _unicode):
            cwd = os.getcwdu()
        else:
            cwd = os.getcwd()
        path = join(cwd, path)
    return normpath(path)


# Return a canonical path (i.e. the absolute location of a file on the
# filesystem). 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:posixpath.py

示例4: abspath

# 需要導入模塊: import genericpath [as 別名]
# 或者: from genericpath import _unicode [as 別名]
def abspath(path):
    """Return the absolute version of a path"""
    if not isabs(path):
        if isinstance(path, _unicode):
            cwd = os.getcwdu()
        else:
            cwd = os.getcwd()
        path = join(cwd, path)
    return normpath(path)

# realpath is a no-op on systems without islink support 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:13,代碼來源:os2emxpath.py

示例5: normpath

# 需要導入模塊: import genericpath [as 別名]
# 或者: from genericpath import _unicode [as 別名]
def normpath(path):
    """Normalize path, eliminating double slashes, etc."""
    # Preserve unicode (if path is unicode)
    slash, dot = (u'/', u'.') if isinstance(path, _unicode) else ('/', '.')
    if path == '':
        return dot
    initial_slashes = path.startswith('/')
    # POSIX allows one or two initial slashes, but treats three or more
    # as single slash.
    if (initial_slashes and
        path.startswith('//') and not path.startswith('///')):
        initial_slashes = 2
    comps = path.split('/')
    new_comps = []
    for comp in comps:
        if comp in ('', '.'):
            continue
        if (comp != '..' or (not initial_slashes and not new_comps) or
             (new_comps and new_comps[-1] == '..')):
            new_comps.append(comp)
        elif new_comps:
            new_comps.pop()
    comps = new_comps
    path = slash.join(comps)
    if initial_slashes:
        path = slash*initial_slashes + path
    return path or dot 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:29,代碼來源:posixpath.py


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