本文整理匯總了Python中distutils.version.LooseVersion.version[i]方法的典型用法代碼示例。如果您正苦於以下問題:Python LooseVersion.version[i]方法的具體用法?Python LooseVersion.version[i]怎麽用?Python LooseVersion.version[i]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類distutils.version.LooseVersion
的用法示例。
在下文中一共展示了LooseVersion.version[i]方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _cmp
# 需要導入模塊: from distutils.version import LooseVersion [as 別名]
# 或者: from distutils.version.LooseVersion import version[i] [as 別名]
def _cmp (self, other):
if isinstance(other, str):
other = LooseVersion(other)
stypes = map(lambda c: str if isinstance(c, str) else int, self.version)
otypes = map(lambda c: str if isinstance(c, str) else int, other.version)
for i, (stype, otype) in enumerate(zip(stypes, otypes)):
if stype == str and otype == int:
other.version[i] = str(other.version[i])
if stype == int and otype == str:
self.version[i] = str(self.version[i])
if self.version == other.version:
return 0
if self.version < other.version:
return -1
if self.version > other.version:
return 1