Commit d056a408 by 杨林龙

优化代码逻辑

1 parent 7bcabaa1
...@@ -75,7 +75,7 @@ ocr = PaddleOCR( ...@@ -75,7 +75,7 @@ ocr = PaddleOCR(
# 定义要执行的SQL语句 # 定义要执行的SQL语句
SQL = """ SQL = """
select * from sys_order_file_ocr sofo select * from sys_order_file_ocr sofo limit 1000
""" """
# 执行SQL语句 # 执行SQL语句
cursor_dev.execute(SQL) cursor_dev.execute(SQL)
...@@ -186,12 +186,17 @@ for index, row in enumerate(result): ...@@ -186,12 +186,17 @@ for index, row in enumerate(result):
result_list = flatten_list(result) result_list = flatten_list(result)
print("result_list", result_list) print("result_list", result_list)
with open("./log07.txt", "a+", encoding="utf-8") as file:
if result_list is not None:
file.write(path + "----" + str(result_list) + "\n")
else:
file.write(path + "----" + "NULL" + "\n")
# 使用正则表达式进行过滤 获取车架号 # 使用正则表达式进行过滤 获取车架号
vin_str = "" vin_str = ""
for item in result_list: for item in result_list:
print(item) print(item)
vin_check = validate_vin(item) vin_check = extract_vin(item)
if vin_check is not None: if vin_check is not None:
vin_str = vin_check vin_str = vin_check
break break
......
...@@ -12,6 +12,6 @@ def extract_vin(string): ...@@ -12,6 +12,6 @@ def extract_vin(string):
# 测试字符串 # 测试字符串
test_string = "This is a test VIN: 1HGCM82633A123456" test_string = "This is a test VIN: 1HGCM82633A123456 GT800"
result = extract_vin(test_string) result = extract_vin(test_string)
print(result) # 输出 1HGCM82633A123456 print(result) # 输出 1HGCM82633A123456
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!