调整金额类数据的处理

This commit is contained in:
2024-07-18 10:43:50 +08:00
parent c44baa12a4
commit 31256a6271

View File

@@ -4,9 +4,9 @@ from datetime import datetime
# 处理金额类数据 # 处理金额类数据
def handle_decimal(string): def handle_decimal(string):
string = re.sub(r'[^0-9.]', '', string)
if not string: if not string:
return "" return ""
string = re.sub(r'[^0-9.]', '', string)
if "." not in string: if "." not in string:
front = string front = string
back = "" back = ""
@@ -17,6 +17,11 @@ def handle_decimal(string):
front = front[-16:] front = front[-16:]
if back: if back:
back = "." + back back = "." + back
result = float(front + back)
# 金额较大的暂且交给人工确认
if result > 100000:
return ""
else:
return front + back return front + back
@@ -156,3 +161,7 @@ def handle_age(string):
string = string.split("")[0] string = string.split("")[0]
num = re.sub(r'\D', '', string) num = re.sub(r'\D', '', string)
return num[-3:] return num[-3:]
if __name__ == '__main__':
print(handle_decimal(" "))