myStr2 = r'<cite>k.189.cn</cite>abcd<cite>st.189.cn</cite>'
pattern = re.compile(r'<cite>*</cite>')
pe = pattern.match(myStr2)
if pe is None:
print('None')
else:
print(pe.group())
為什么匹配不到呢?
uj5u.com熱心網友回復:
myStr2 = r'<cite>k.189.cn</cite>abcd<cite>st.189.cn</cite>'pattern = re.compile(r'<cite>([^<>\/].+?)</cite>')
pe = pattern.findall(myStr2)
if pe is None:
print('None')
else:
print(pe)
這樣就可以了
uj5u.com熱心網友回復:
幫結帖+蹭分轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/284438.html
上一篇:大佬們,關于python調java介面,傳json中文為ascii碼問題
下一篇:cmd命令執行"python test_login.py",系統報錯:E Time Elapsed 0:00:00
