1
我有下面的代碼的結果:輸出的RE
import re
targetFile = open("test.txt").read()
print(re.search('(<\\/nesting_tag>)',targetFile))
的想法是我回報之間的一切。例如。測試時「測試」。如何返回「測試」而不是< _sre.SRE_Match對象; span =(56,70),match =''>?
我有下面的代碼的結果:輸出的RE
import re
targetFile = open("test.txt").read()
print(re.search('(<\\/nesting_tag>)',targetFile))
的想法是我回報之間的一切。例如。測試時「測試」。如何返回「測試」而不是< _sre.SRE_Match對象; span =(56,70),match =''>?
試試這個
print(re.search('(<\\/nesting_tag>)',targetFile).group())
給一個適當的例子輸入請。 – Jerry
@JHarley如果我的答案解決了您的問題,請確認。謝謝! –