修正全角数字存入数据库失败的问题
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
x-env:
|
x-env:
|
||||||
&template
|
&template
|
||||||
image: fcb_photo_review:1.14.15
|
image: fcb_photo_review:1.14.16
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
x-review:
|
x-review:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import logging
|
|||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from util import util
|
from util import util, string_util
|
||||||
|
|
||||||
|
|
||||||
# 处理金额类数据
|
# 处理金额类数据
|
||||||
@@ -12,6 +12,7 @@ def handle_decimal(string):
|
|||||||
string = re.sub(r'[^0-9.]', '', string)
|
string = re.sub(r'[^0-9.]', '', string)
|
||||||
if not string:
|
if not string:
|
||||||
return ""
|
return ""
|
||||||
|
string = string_util.full_to_half(string)
|
||||||
if "." not in string:
|
if "." not in string:
|
||||||
if len(string) > 2:
|
if len(string) > 2:
|
||||||
result = string[:-2] + "." + string[-2:]
|
result = string[:-2] + "." + string[-2:]
|
||||||
@@ -182,7 +183,7 @@ def handle_settlement_id(string):
|
|||||||
def handle_age(string):
|
def handle_age(string):
|
||||||
if not string:
|
if not string:
|
||||||
return ""
|
return ""
|
||||||
string = string.split("岁")[0]
|
string = string_util.full_to_half(string.split("岁")[0])
|
||||||
num = re.sub(r'\D', '', string)
|
num = re.sub(r'\D', '', string)
|
||||||
return num[-3:]
|
return num[-3:]
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import unicodedata
|
||||||
|
|
||||||
|
|
||||||
def blank(string):
|
def blank(string):
|
||||||
"""
|
"""
|
||||||
判断字符串是否为空或者纯空格
|
判断字符串是否为空或者纯空格
|
||||||
@@ -5,3 +8,23 @@ def blank(string):
|
|||||||
:return: 字符串是否为空或者纯空格
|
:return: 字符串是否为空或者纯空格
|
||||||
"""
|
"""
|
||||||
return not string or string.isspace()
|
return not string or string.isspace()
|
||||||
|
|
||||||
|
|
||||||
|
def full_to_half(string):
|
||||||
|
"""
|
||||||
|
全角转半角
|
||||||
|
:param string: 字符串
|
||||||
|
:return: 半角字符串
|
||||||
|
"""
|
||||||
|
if not isinstance(string, str):
|
||||||
|
raise TypeError("全角转半角的输入必须是字符串类型")
|
||||||
|
|
||||||
|
if not string:
|
||||||
|
return string
|
||||||
|
|
||||||
|
half_string = ''.join([
|
||||||
|
unicodedata.normalize('NFKC', char) if unicodedata.east_asian_width(char) in ['F', 'W'] else char
|
||||||
|
for char in string
|
||||||
|
])
|
||||||
|
|
||||||
|
return half_string
|
||||||
|
|||||||
Reference in New Issue
Block a user