Commit 597c0e52 by 岳巧源

add is_number

parent 49d6b824
Showing with 16 additions and 0 deletions
......@@ -53,6 +53,20 @@ class Producer:
except Exception as e:
print(e)
"""判断传入的字符串是不是数字"""
def is_number(s: str):
try:
float(s)
return True
except ValueError:
pass
try:
import unicodedata
unicodedata.numeric(s)
return True
except (TypeError, ValueError):
pass
return False
def resolve(file_name: str, supplier_id: int):
producer = Producer()
......@@ -105,6 +119,8 @@ def resolve(file_name: str, supplier_id: int):
for index in range(1, 6):
ladder_data = df.loc[i, "阶梯数量" + str(index)]
price_data = df.loc[i, "价格" + str(index)]
if not is_number(str(price_data)) or not is_number(str(ladder_data)):
continue
if str(ladder_data).strip() != "" and str(ladder_data).strip() != "nan" and str(ladder_data).strip() != "NaN" and \
str(price_data).strip() != "" and str(price_data).strip() != "nan" and str(price_data).strip() != "NaN":
item_map = dict()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment