python compare string_Python compare-string-version包_程序模块 - PyPI - Python中文网

这是一个软件库,它接受2个版本字符串作为输入,并且

返回一个是否大于、等于或小于另一个。

例如:“1.2”大于“1.1”。

要求:python 3。及以上

用法:from compare_string_version import compareVersion

print(compareVersion(a,b))

预期收益

当a==b:

a is equal to b

a>b:

a is greater than b

a

a is less than b

例外情况:

a为空和/或b为空:

值不能为空:两个值都必须为字符串

a和/或b不是字符串:

两者都必须是字符串

假设:a and b are string

a and b are not null (None)

both version strings only contain numbers (0...9) and this char '.':

123.456.789.012

'A..Z','a..z' and any other chars like "! @ # $ % * [ } ] { ^ ç ? ; : . > , < | " will be removed from the comparison:

some adjustment would be applied after char removal:

'..' will be replaced by '.'

string ending in '.' will be shorted by 1

this '..' will not be accepted as it is '.' duplicated:

'10..12..13..14' will become '10.12.13.14'

the comparison would be from the group split by the char '.':

10.12.13.14 would be treated as 10 12 13 14

01.10.100.001 would be treated as 1 10 100 1

all the comparison would check the integer part of the version:

'10.0' is equal to '010.0.0.0.0.0.0.0' because int('10.0') is equal to int ('010')

whoever version number has the higher far left group would be named as greater:

10.0.0.0.0.1 is greater then 9.9.9.9.9.9.9

0.1.0.0.0.0.1 is greater than 0.0.9

the same "int" rule will be applied for any other group in the string

all '0's from the left will be disregarded if its value is '0':

1.0.0.0 is equal to 1.0 and it is equal to 1

使用以下.py来测试数据

test997.py已生成output5.txt

test996.py已生成output4.txt

test995.py生成了output1.txt和output2.txt

test994.py已生成output3.txt

欢迎加入QQ群-->: 979659372

推荐PyPI第三方库

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值