[python中有sublist3r的功能,我很了解

问题描述 投票:-1回答:1
        link_regx = re.compile('<cite.*?>(.*?)<\/cite>')
        try:
            links_list = link_regx.findall(resp)
            for link in links_list:
                link = re.sub('<span.*>', '', link)

是什么compile()和sub()在此使用功能

python python-3.x subdomain
1个回答
0
投票

re.compile(pattern,flags = 0)

将正则表达式模式编译为正则表达式对象,可以使用其match(),search()和其他方法进行匹配。

https://docs.python.org/3/library/re.html#re.compile

re.sub(pattern,repl,string,count = 0,flags = 0)

返回用替换代表替换字符串中最左边的非重叠模式所获得的字符串。

https://docs.python.org/3/library/re.html#re.sub

© www.soinside.com 2019 - 2024. All rights reserved.