20220328-day17:re.match使用group和groups方法返回值区别
import re
while True:
text = input("请输入搜索条件,支持 [ id=1711349 或 key=文本 ](Q/q退出):")
if text.upper() == 'Q':
break
match_object = re.match("(id|key)=(\w+)", text.strip())
if not match_object:
print("输入格式错误,请重新输入")
continue
v1 = match_object.group() # "id=1711349"
print(v1)
name, value = match_object.groups()
print(name,value) # id 1711349