首页 > 代码库 > re模块中的compile函数
re模块中的compile函数
compile
compile(pattern,flag=0)
compile a regular expression pattern,return a pattern object
compile就像一个漏斗,指定漏斗规则,如三角形通过,圆形通过,字母通过,汉字通过等等,具体漏什么东西(str数值),可以使用的时候再决定
myCompile = re.compile(‘d‘)#指定漏斗规则 re.compile是个函数,但是返回值是个类,一个过滤方法的类,实例化后就可以用来过滤东西
myStr0 = ‘today 12 is 34 so 56 beautiful 789‘#str数值
myResult=myCompile.find_all(myStr0)#过滤str0
flags是个标记,就像吃东西会标注微辣、麻辣、不辣一样,flags是个证书值,但是不太好记,python帮大家记住。
re模块中的compile函数
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。