所以我正在尝试使用re模块来查看数字板是否与数字板的匹配方式相匹配,但我不断收到模块的错误,我的代码在下面。
def nplatec():
import re
r_plate = "^[Aa-Zz]{2}[0-9][Aa-Zz]{3}$"
while True:
u_plate = input("Enter your number plate WITHOUT spaces please : ")
a_speed = int(input("Enter you average speed : "))
s_limit = 70
if re.match(r_plate, u_plate):
print("InCorrect number plate")
break
nplatec()
错误:
答案 0 :(得分:0)
我找到了答案,其意思是"^[A-Za-z]{2}[0-9][A-Za-z]{3}$"
而不是"^[Aa-Zz]{2}[0-9][Aa-Zz]{3}$"