Python中时间模式的正则表达式。小时[1-12],后跟:分钟[00:59],后接可选空格和上午或下午(大写或小写))>
pattern = r"^(1[0-2]|0?[1-9]):([0-5]?[0-9])(\s?[AP]M)?$ "
result = re.search(pattern, text)
return result != None
print(check_time("12:45pm")) # True
print(check_time("9:59 AM")) # True
print(check_time("6:60am")) # False
print(check_time("five o'clock")) # False```
Python中时间模式的正则表达式。小时[1-12],后跟:分钟[00:59],后跟可选空格,以及(大写或小写)模式中的am或PM = r“ ^(1 [0-2] | 0?[1-9]) :([[0-5]?[...
您需要: