如何比较python的版本号

如何比较python的版本号,python,Python,如果我有这个 a = "4.1.3.79" b = "4.1.3.64" 我怎样才能使这个比较返回真值 我不能使用float或int,python也不能将4.1.2.79识别为一个数字,我如何与这些类型的值进行比较 我已经阅读了StrictVersion,但这只会增加到第三个版本号,而不是第四个 这将起作用: a = "4.1.2.79" b = "4.1.3.64" #split it a_list = a.split('.') b_list = b.split('.') #to look

如果我有这个

a = "4.1.3.79"
b = "4.1.3.64"
我怎样才能使这个比较返回真值

我不能使用float或int,python也不能将4.1.2.79识别为一个数字,我如何与这些类型的值进行比较

我已经阅读了StrictVersion,但这只会增加到第三个版本号,而不是第四个

这将起作用:

a = "4.1.2.79"
b = "4.1.3.64"
#split it
a_list = a.split('.')
b_list = b.split('.')
#to look if a is bigger or not
a_bigger = False
#compare it number by number in list
for i in range(0, len(a_list)):
    #make from both lists one integer
    a_num = int(a_list[i])
    b_num = int(b_list[i])
    #if one num in the a_list is bigger
    if a_num > b_num:
        #make this variable True
        a_bigger = True
        #break the loop so it will show the results
    #else it wil look to the other nums in the lists
#print the result
print('a > b: %s' % str(a_bigger))
a = "4.1.2.79"
b = "4.1.3.64"
#split it
a_list = a.split('.')
b_list = b.split('.')
#to look if a is bigger or not
a_bigger = False
#compare it number by number in list
for i in range(0, len(a_list)):
    #make from both lists one integer
    a_num = int(a_list[i])
    b_num = int(b_list[i])
    #if one num in the a_list is bigger
    if a_num > b_num:
        #make this variable True
        a_bigger = True
        #break the loop so it will show the results
    #else it wil look to the other nums in the lists
#print the result
print('a > b: %s' % str(a_bigger))