Python中有一个我不理解的功能


link_regx = re.compile('<cite.*?>(.*?)</cite>')
try:
links_list = link_regx.findall(resp)
for link in links_list:
link = re.sub('<span.*>', '', link)

什么 编译(( 和子 (( 此处使用函数

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(

返回通过将字符串中最左侧的非重叠模式替换为替换 repl 而获得的字符串。

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

最新更新