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

必须加# 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

猜你喜欢

转载自www.cnblogs.com/taoshihan/p/12325153.html