import re
a = "我"
b = "你"
str = "fgsdgf我dsfghjfgfdgdff你fgdgfdfgd"
用re.search()方法取出 '我' 和 '你' 中间的部分
result=re.search(“123456”,str)
最好给出多种方法,能给出多种方法的优先采纳!
a = "我"
b = "你"
str = "fgsdgf我dsfghjfgfdgdff你fgdgfdfgd"
result=re.search(“123456”,str)
最好给出多种方法,能给出多种方法的优先采纳!
import re
a = "我"
b = "你"
str = "fgsdgf我dsfghjfgfdgdff你fgdgfdfgd"
result = re.search(a + '(.+?)' + b, str).group()[1:-1]
resiult1 = re.search(f'{a}.*(?={b})', str).group()[1:]
print(result)
print(resiult1)