python学习之re 20 purge() exception

re. purge ( )

Clear the regular expression cache.

翻译:清空RE表达式缓存。

exception  re. error ( msgpattern=Nonepos=None )

Exception raised when a string passed to one of the functions here is not a valid regular expression (for example, it might contain unmatched parentheses) or when some other error occurs during compilation or matching. It is never an error if a string contains no match for a pattern. The error instance has the following additional attributes:
翻译:当传入的RE表达式对于这个方法不合法时,就会抛出异常(比如,不匹配的括号)或者是在编译和匹配是遇到的异常。如果遇到源串没有匹配RE表达式,这种不算错误。ERROR实例拥有以下属性

msg

The unformatted error message.

pattern

The regular expression pattern.

pos

The index in pattern where compilation failed (may be None).

lineno

The line corresponding to pos (may be None).

colno

The column corresponding to pos (may be None).

Changed in version 3.5: Added additional attributes.






猜你喜欢

转载自blog.csdn.net/rubikchen/article/details/80509263