使用正则匹配数字

import re
pattern = '\d+?\.\d+'
s = "[Decimal('90.900000')]"
s2 = "[Decimal('75.900000'),Decimal('57.280000')]"
[print(i,end = " ") for i in re.findall(pattern,s)]
print()
[print(i,end = " ") for i in re.findall(pattern,s2)]


2020-05-27

猜你喜欢

转载自www.cnblogs.com/hany-postq473111315/p/12971958.html
今日推荐