优化金额类数据的处理,限制长度

This commit is contained in:
2024-06-18 16:56:45 +08:00
parent e65ca1d475
commit 2eb35b637f

View File

@@ -8,9 +8,12 @@ def handle_decimal(string):
return "" return ""
string = re.sub(r'[^0-9.]', '', string) string = re.sub(r'[^0-9.]', '', string)
if "." not in string: if "." not in string:
return string front = string
front, back = string.rsplit('.', 1) back = ""
front = front.replace(".", "") else:
front, back = string.rsplit('.', 1)
front = front.replace(".", "")
front = front[-16:] front = front[-16:]
if back: if back:
back = "." + back back = "." + back