1. 说明
我本来是想匹配时间的,无意中发现包含中文的字符串,总体的匹配无法输出,就是 print m.group(0)和 print m.group(1)会报错,这是为什么呢?
2. CODE
# coding=utf-8
timestr= u"2018 年 3 月 28 日"
m = re.match(u"((\d+)年(\d+)月(\d+)日)", timestr)
print m.group(0)
print m.group(1)
print m.group(2)
print m.group(3)