Type of compiled regex object in python

后端 未结 10 1085
一个人的身影
一个人的身影 2020-11-30 07:14

What is the type of the compiled regular expression in python?

In particular, I want to evaluate

isinstance(re.compile(\'\'), ???)

10条回答
  •  悲&欢浪女
    2020-11-30 07:38

    In 3.7 you can use re.Pattern:

    import re
    rr = re.compile("pattern")
    isinstance(rr, re.Pattern)
    >> True
    

提交回复
热议问题