原文:https://blog.csdn.net/your_answer/article/details/80456550

 

 

import re
 
string = 'abe(ac)ad)'
p1 = re.compile(r'[(](.*?)[)]', re.S)  #最小匹配
p2 = re.compile(r'[(](.*)[)]', re.S)   #贪婪匹配
print(re.findall(p1, string))
print(re.findall(p2, string))

 

功能:获取括号里面的字符串

import re
import numpy
 
string = 'abe(ac)ad)'
p1 = re.compile(r'[(](.*?)[)]', re.S) 
arr = re.findall(p1, string)
print(arr[0])

 

相关文章:

  • 2021-08-27
  • 2021-06-30
  • 2021-11-20
  • 2022-12-23
  • 2022-01-18
  • 2021-11-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-25
  • 2021-06-02
  • 2022-12-23
  • 2021-12-24
  • 2022-12-23
相关资源
相似解决方案