之前做数据处理,通常用c#: MatchCollection mc=reg.Matches(mystr); 在python里面做匹配的话 import re result = re.findall(r'(\w+)=(\d+)’, ‘set width=20 and height=10’) print(result)