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


Python posixpath.commonprefix方法代碼示例

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


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

示例1: test_commonprefix

# 需要導入模塊: import posixpath [as 別名]
# 或者: from posixpath import commonprefix [as 別名]
def test_commonprefix(self):
        self.assertEqual(
            posixpath.commonprefix([]),
            ""
        )
        self.assertEqual(
            posixpath.commonprefix(["/home/swenson/spam", "/home/swen/spam"]),
            "/home/swen"
        )
        self.assertEqual(
            posixpath.commonprefix(["/home/swen/spam", "/home/swen/eggs"]),
            "/home/swen/"
        )
        self.assertEqual(
            posixpath.commonprefix(["/home/swen/spam", "/home/swen/spam"]),
            "/home/swen/spam"
        ) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:19,代碼來源:test_posixpath.py

示例2: is_suburi

# 需要導入模塊: import posixpath [as 別名]
# 或者: from posixpath import commonprefix [as 別名]
def is_suburi(self, base, test):
        """Check if test is below base in a URI tree

        Both args must be URIs in reduced form.
        """
        if base == test:
            return 1
        if base[0] != test[0]:
            return 0
        common = posixpath.commonprefix((base[1], test[1]))
        if len(common) == len(base[1]):
            return 1
        return 0 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:15,代碼來源:urllib2.py

示例3: is_suburi

# 需要導入模塊: import posixpath [as 別名]
# 或者: from posixpath import commonprefix [as 別名]
def is_suburi(self, base, test):
        """Check if test is below base in a URI tree

        Both args must be URIs in reduced form.
        """
        if base == test:
            return True
        if base[0] != test[0]:
            return False
        common = posixpath.commonprefix((base[1], test[1]))
        if len(common) == len(base[1]):
            return True
        return False 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:15,代碼來源:request.py


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