正则匹配键值对 问题 字符串: aaa=“bbb” ccc=“ddd” 目标:{‘test’: ‘bbb’, ‘test1’: ‘ddd’} 正则 import re pattern = re.compile(r'aaa="(?P<test>\w*)"\s*ccc="(?P<test1>\w*)"') m = pattern.search(r'aaa="bbb" ccc="ddd"') print(m.groupdict()) #{'test': 'bbb', 'test1': 'ddd'}