例如一个字符串:'American(UnitedStatesof)'要提取出:'(UnitedStatesof)'又或者'Abcde(DfWDasdASASDW)'提取出:'(DfWDasdASASDW)'要用正则表达式的方式谢谢各位大佬了
2 回答
宝慕林4294392
TA贡献2021条经验 获得超8个赞
importreIn[26]:re.findall(r'.*(\(.*\)).*','American(UnitedStatesof)')Out[26]:['(UnitedStatesof)']In[31]:m=re.match(r'.*(\(.*\)).*','American(UnitedStatesof)')In[32]:ifm:...:print(m.groups())...:('(UnitedStatesof)',)
添加回答
举报
0/150
提交
取消