因为您应该将传递给
re.I而
compile()不是
match()。
>>> pattern = re.compile(r'^9', re.I)>>> a=pattern.match(teststring)>>> print a<_sre.SRE_Match object at 0x1140168>

因为您应该将传递给
re.I而
compile()不是
match()。
>>> pattern = re.compile(r'^9', re.I)>>> a=pattern.match(teststring)>>> print a<_sre.SRE_Match object at 0x1140168>