>>lp_name='./problems/car_license_plate.jpg'
>>text_description=str(get_text_description(lp_name))
>>text_description
[output] 'АЕВ 329\nICT-ISLAMABAD\'
>>License_plate=extract_registration_ID(text_description)
>>License_plate
[output] ['АЕВ329']
>>split_strings_numbers=splitString(License_plate)
>>def splitString(lp_without_district):
import re
splitted=[]
for i in range(len(lp_without_district)):
if lp_without_district[i][0].isdigit()==False and lp_without_district[i][-1].isdigit()==True:
temp = re.compile("([a-zA-Z]+)([0-9]+)")
res = temp.match(lp_without_district[i]).groups()
elif lp_without_district[i][0].isdigit()==True and lp_without_district[i][-1].isdigit()==False:
temp = re.compile("([0-9]+)([a-zA-Z]+)")
res = temp.match(lp_without_district[i]).groups()
else:
res=[lp_without_district[i]]
for i in range(len(res)):
splitted.append(res[i])
return splitted
AttributeError跟踪(最近一次通话) 在 30打印('注册号为空') 31#分割字符串和数字 ---> 32 split_strings_numbers = splitString(lp_without_district) 33 34打印(split_strings_numbers)
splitString中的(lp_without_district) 140 #print(lp_without_district [i] [0],'--------',lp_without_district [i] [-1]) 141 temp = re.compile(“([[a-zA-Z] +)([0-9] +)”) -> 142 res = temp.match(lp_without_district [i])。groups() 143 elif lp_without_district [i] [0] .isdigit()==真和lp_without_district [i] [-1] .isdigit()== False: 144 #print(lp_without_district [i] [0],'--------',lp_without_district [i] [-1])
AttributeError:'NoneType'对象没有属性'groups'
[output] ['AEB', '329']
>>len(License_plate[0])
[output] 6
>>type(License_plate[0])
[output] str
>>License_plate=['АЕВ329']
>>len(License_plate[0])
[output] 6
>>type(License_plate[0])
[output] str