我在写一个脚本,在这里我需要比较binnaries的版本,比如我需要得到10.2.3大于10.1.30。如果我去掉点,我将得到1023和10130,这使我的比较颠倒过来。你知道吗
10.2.3 > 10.1.30 == 1023 !> 10130
到目前为止,我得出的唯一解决办法是:
1. do split(".") on version number
2. for each elemet of list i got, check if len() is eq 1 , add one zero from the left.
3. glue all elements together and get int (10.1.30 will became 100130).
4. process second version number same way and compare both as regular ints.
这样:
10.2.3 > 10.1.30 == 100203 > 100130
这是比较版本的唯一方法还是其他方法?你知道吗
您可以借用
distutils
及其继承者用来比较版本号的代码您可以尝试:
相关问题 更多 >
编程相关推荐