【发布时间】:2026-01-05 19:00:01
【问题描述】:
我有一个列表列表,其中包含两个元素 ["Name", "Version"],所有列表的名称都相同。
[[N1, V1] , [N1, V2], [N1, V3], [N1,V4], [N1,V5] .....[N1,Vn] ]
我想要满足以下条件的两个版本 'Vx' 和 'Vy' 之间的所有 [N1,Vi] 对:
仅在以下情况下检索 Vx 和 Vy 之间的 [N1,Vi] 对:Vy > Max(Vi)
(即版本上限(Vy)大于列表中版本的最大值时)
我尝试过使用:
from distutils.version import LooseVersion, StrictVersion
但我只能找到布尔结果。
[["pshop","4.6.23.1"], ["pshop","4.6.10"], ["pshop","4.0.1"],
["pshop","6.8.1"], ["pshop","5.6.23.1"], ["pshop","7.6.23.1"]]
1. If Vx = (5.5.7) Vy = (9.34.1)
In this case it will return lists which have version numbers between Vx and Vy
[["pshop","6.8.1"], ["pshop","5.6.23.1"], ["pshop","7.6.23.1"]]
2. If Vx = (2.5.7) Vy = (6.0.0)
In this case it should return [] as Vy < max(Vi) (6.0.0 < 7.6.23.1)
【问题讨论】:
标签: python python-3.x python-2.7 version string-comparison