我这里有任何字面值吗?

问题描述 投票:0回答:0
input_format = re.compile(r"^(0[1-9]|1[012])/(0[1-9]|[12][0-9]|3[01])/[1-9]\d{3}$")
leap_year = re.compile(r"^(02/(0[1-9]|[12][0-9])/[1-9]\d{3})$")
not_leap_year = re.compile(r"^(02/(0[1-9]|1[0-9]|2[0-8])/[1-9]\d{3})$")
until_thirty = re.compile(r"^(0[1-9]|1[012])/(0[1-9]|[12][0-9]|30)/[1-9]\d{3}$")

我这里有文字价值吗?如果有,我如何将其更改为命名常量?

试图消除每个文字值并将它们替换为命名常量。

python regex literals
© www.soinside.com 2019 - 2024. All rights reserved.