zl程序教程

您现在的位置是:首页 >  Python

当前栏目

[Python]Python中使用正则表达式匹配

2023-02-18 15:41:35 时间

必须加# encoding: utf-8否则报错

SyntaxError: Non-ASCII character '\xe6'

 

# encoding: utf-8
import re
regex= ur"\d{4}" #正则表达式
if re.match(regex,"2020-2-02"):
    print 111
else:
    print 222

 

返回111