[Fix]Close #638
This commit is contained in:
parent
38338ddbc0
commit
1307d637ec
@ -8,18 +8,18 @@ import os
|
|||||||
import decimal
|
import decimal
|
||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from math import isnan
|
||||||
|
|
||||||
|
|
||||||
MAX_NUMBER = 10000000000000
|
MAX_NUMBER = 10000000000000
|
||||||
MAX_DECIMAL = 4
|
MAX_DECIMAL = 4
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def safeUnicode(value):
|
def safeUnicode(value):
|
||||||
"""检查接口数据潜在的错误,保证转化为的字符串正确"""
|
"""检查接口数据潜在的错误,保证转化为的字符串正确"""
|
||||||
# 检查是数字接近0时会出现的浮点数上限
|
# 检查是数字接近0时会出现的浮点数上限
|
||||||
if type(value) is int or type(value) is float:
|
if type(value) is int or type(value) is float:
|
||||||
if value > MAX_NUMBER:
|
if value > MAX_NUMBER or isnan(value):
|
||||||
value = 0
|
value = 0
|
||||||
|
|
||||||
# 检查防止小数点位过多
|
# 检查防止小数点位过多
|
||||||
|
Loading…
Reference in New Issue
Block a user